From 7ed4be96ebe2e973a6f4643e13a6bc2d801059a4 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 29 May 2018 16:01:11 +0200 Subject: [PATCH] impl IntoAttributeValue for std::net::IpAddr --- CHANGELOG.md | 2 ++ src/convert.rs | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e7062a..dc1fadc 100644 --- a/CHANGELOG.md +++ b/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 diff --git a/src/convert.rs b/src/convert.rs index 1b35414..1a52811 100644 --- a/src/convert.rs +++ b/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 { @@ -132,6 +132,8 @@ impl IntoAttributeValue for Option { #[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"); } }