mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-12 21:21:02 +00:00
Use deserializer.visit_string for PathBuf
This commit is contained in:
@@ -762,7 +762,7 @@ impl Deserialize for path::PathBuf {
|
|||||||
fn deserialize<D>(deserializer: &mut D) -> Result<path::PathBuf, D::Error>
|
fn deserialize<D>(deserializer: &mut D) -> Result<path::PathBuf, D::Error>
|
||||||
where D: Deserializer,
|
where D: Deserializer,
|
||||||
{
|
{
|
||||||
deserializer.visit(PathBufVisitor)
|
deserializer.visit_string(PathBufVisitor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
|
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use num::FromPrimitive;
|
use num::FromPrimitive;
|
||||||
use num::bigint::{BigInt, BigUint};
|
use num::bigint::{BigInt, BigUint};
|
||||||
@@ -589,4 +590,9 @@ declare_tests! {
|
|||||||
Token::SeqEnd,
|
Token::SeqEnd,
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
test_path_buf {
|
||||||
|
PathBuf::from("/usr/local/lib") => vec![
|
||||||
|
Token::String("/usr/local/lib".to_owned()),
|
||||||
|
],
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use num::FromPrimitive;
|
use num::FromPrimitive;
|
||||||
use num::bigint::{BigInt, BigUint};
|
use num::bigint::{BigInt, BigUint};
|
||||||
@@ -293,4 +294,14 @@ declare_ser_tests! {
|
|||||||
Token::SeqEnd,
|
Token::SeqEnd,
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
test_path {
|
||||||
|
Path::new("/usr/local/lib") => &[
|
||||||
|
Token::Str("/usr/local/lib"),
|
||||||
|
],
|
||||||
|
}
|
||||||
|
test_path_buf {
|
||||||
|
PathBuf::from("/usr/local/lib") => &[
|
||||||
|
Token::Str("/usr/local/lib"),
|
||||||
|
],
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user