mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-22 21:48:02 +00:00
feat(impls): Add impls for std::net::Ip{,v4,v6}Addr
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
|
||||
use std::net;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use num::FromPrimitive;
|
||||
@@ -571,6 +572,12 @@ declare_tests! {
|
||||
Token::Unit,
|
||||
],
|
||||
}
|
||||
test_net_ipv4addr {
|
||||
"1.2.3.4".parse::<net::Ipv4Addr>().unwrap() => vec![Token::Str("1.2.3.4")],
|
||||
}
|
||||
test_net_ipv6addr {
|
||||
"::1".parse::<net::Ipv6Addr>().unwrap() => vec![Token::Str("::1")],
|
||||
}
|
||||
test_num_bigint {
|
||||
BigInt::from_i64(123).unwrap() => vec![Token::Str("123")],
|
||||
BigInt::from_i64(-123).unwrap() => vec![Token::Str("-123")],
|
||||
@@ -607,6 +614,15 @@ declare_tests! {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "nightly")]
|
||||
#[test]
|
||||
fn test_net_ipaddr() {
|
||||
assert_de_tokens(
|
||||
"1.2.3.4".parse::<net::IpAddr>().unwrap(),
|
||||
vec![Token::Str("1.2.3.4")],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_enum_error() {
|
||||
assert_de_tokens_error::<Enum>(
|
||||
|
||||
Reference in New Issue
Block a user