Serialize unsized Arc and Rc

This commit is contained in:
David Tolnay
2017-09-04 10:16:03 -07:00
parent 7650a48fdd
commit e4ea2a56e9
3 changed files with 40 additions and 3 deletions
+37
View File
@@ -14,6 +14,8 @@ use std::net;
use std::path::{Path, PathBuf};
use std::time::{Duration, UNIX_EPOCH};
use std::ffi::CString;
use std::rc::Rc;
use std::sync::Arc;
#[cfg(unix)]
use std::str;
@@ -383,6 +385,41 @@ declare_tests! {
Token::Bytes(b"abc"),
],
}
test_rc {
Rc::new(true) => &[
Token::Bool(true),
],
}
test_arc {
Arc::new(true) => &[
Token::Bool(true),
],
}
}
// Serde's implementation is not unstable, but the constructors are.
#[cfg(feature = "unstable")]
declare_tests! {
test_rc_dst {
Rc::<str>::from("s") => &[
Token::Str("s"),
],
Rc::<[bool]>::from(&[true][..]) => &[
Token::Seq { len: Some(1) },
Token::Bool(true),
Token::SeqEnd,
],
}
test_arc_dst {
Arc::<str>::from("s") => &[
Token::Str("s"),
],
Arc::<[bool]>::from(&[true][..]) => &[
Token::Seq { len: Some(1) },
Token::Bool(true),
Token::SeqEnd,
],
}
}
#[cfg(feature = "unstable")]