impl IntoAttributeValue for std::net::IpAddr

Emmanuel Gil Peyrot created

Change summary

CHANGELOG.md   | 2 ++
src/convert.rs | 5 ++++-
2 files changed, 6 insertions(+), 1 deletion(-)

Detailed changes

CHANGELOG.md 🔗

@@ -1,6 +1,8 @@
 Version 0.9.1, released 2018-05-29:
   * Fixes
     * Lumi fixed CDATA handling, minidom will not unescape CDATA bodies anymore.
+  * Small changes
+    - Link Mauve implemented IntoAttributeValue on std::net::IpAddr.
 Version 0.9.0, released 2018-04-10:
   * Small changes
     - Upgrade quick_xml to 0.12.1

src/convert.rs 🔗

@@ -103,7 +103,7 @@ macro_rules! impl_into_attribute_values {
     }
 }
 
-impl_into_attribute_values!(usize, u64, u32, u16, u8, isize, i64, i32, i16, i8);
+impl_into_attribute_values!(usize, u64, u32, u16, u8, isize, i64, i32, i16, i8, ::std::net::IpAddr);
 
 impl IntoAttributeValue for String {
     fn into_attribute_value(self) -> Option<String> {
@@ -132,6 +132,8 @@ impl<T: IntoAttributeValue> IntoAttributeValue for Option<T> {
 #[cfg(test)]
 mod tests {
     use super::IntoAttributeValue;
+    use std::net::IpAddr;
+    use std::str::FromStr;
 
     #[test]
     fn test_into_attribute_value_on_ints() {
@@ -143,5 +145,6 @@ mod tests {
         assert_eq!((-17i16).into_attribute_value().unwrap(), "-17");
         assert_eq!(   18i32.into_attribute_value().unwrap(), "18");
         assert_eq!((-19i64).into_attribute_value().unwrap(), "-19");
+        assert_eq!(IpAddr::from_str("127.000.0.1").unwrap().into_attribute_value().unwrap(), "127.0.0.1");
     }
 }