mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-14 08:11:02 +00:00
Deserialize Box<Path> through PathBuf::into_boxed_path
Including Rc<Path> et al. Fixes https://github.com/serde-rs/serde/issues/1633
This commit is contained in:
+2
-1
@@ -29,8 +29,9 @@ fn main() {
|
|||||||
println!("cargo:rustc-cfg=core_reverse");
|
println!("cargo:rustc-cfg=core_reverse");
|
||||||
}
|
}
|
||||||
|
|
||||||
// CString::into_boxed_c_str stabilized in Rust 1.20:
|
// CString::into_boxed_c_str and PathBuf::into_boxed_path stabilized in Rust 1.20:
|
||||||
// https://doc.rust-lang.org/std/ffi/struct.CString.html#method.into_boxed_c_str
|
// https://doc.rust-lang.org/std/ffi/struct.CString.html#method.into_boxed_c_str
|
||||||
|
// https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.into_boxed_path
|
||||||
if minor >= 20 {
|
if minor >= 20 {
|
||||||
println!("cargo:rustc-cfg=de_boxed_c_str");
|
println!("cargo:rustc-cfg=de_boxed_c_str");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1610,6 +1610,9 @@ impl<'de> Deserialize<'de> for PathBuf {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(all(feature = "std", de_boxed_c_str))]
|
||||||
|
forwarded_impl!((), Box<Path>, PathBuf::into_boxed_path);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// If this were outside of the serde crate, it would just use:
|
// If this were outside of the serde crate, it would just use:
|
||||||
|
|||||||
@@ -907,6 +907,20 @@ declare_tests! {
|
|||||||
Token::ByteBuf(b"/usr/local/lib"),
|
Token::ByteBuf(b"/usr/local/lib"),
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
test_boxed_path {
|
||||||
|
PathBuf::from("/usr/local/lib").into_boxed_path() => &[
|
||||||
|
Token::Str("/usr/local/lib"),
|
||||||
|
],
|
||||||
|
PathBuf::from("/usr/local/lib").into_boxed_path() => &[
|
||||||
|
Token::String("/usr/local/lib"),
|
||||||
|
],
|
||||||
|
PathBuf::from("/usr/local/lib").into_boxed_path() => &[
|
||||||
|
Token::Bytes(b"/usr/local/lib"),
|
||||||
|
],
|
||||||
|
PathBuf::from("/usr/local/lib").into_boxed_path() => &[
|
||||||
|
Token::ByteBuf(b"/usr/local/lib"),
|
||||||
|
],
|
||||||
|
}
|
||||||
test_cstring {
|
test_cstring {
|
||||||
CString::new("abc").unwrap() => &[
|
CString::new("abc").unwrap() => &[
|
||||||
Token::Bytes(b"abc"),
|
Token::Bytes(b"abc"),
|
||||||
|
|||||||
Reference in New Issue
Block a user