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:
parent
42990d8264
commit
b8772a1e40
@ -29,8 +29,9 @@ fn main() {
|
||||
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/path/struct.PathBuf.html#method.into_boxed_path
|
||||
if minor >= 20 {
|
||||
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:
|
||||
|
@ -907,6 +907,20 @@ declare_tests! {
|
||||
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 {
|
||||
CString::new("abc").unwrap() => &[
|
||||
Token::Bytes(b"abc"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user