mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-26 23:37:55 +00:00
#[derive_deserialize] for generic tuple structs
This commit is contained in:
@@ -30,10 +30,6 @@ trait Trait {
|
||||
#[derive_deserialize]
|
||||
struct NamedUnit;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive_serialize]
|
||||
struct NamedTuple<'a, 'b, A: 'a, B: 'b, C>(&'a A, &'b mut B, C);
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive_serialize]
|
||||
struct NamedMap<'a, 'b, A: 'a, B: 'b, C> {
|
||||
@@ -87,7 +83,11 @@ fn test_named_unit() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_named_tuple() {
|
||||
fn test_ser_named_tuple() {
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive_serialize]
|
||||
struct NamedTuple<'a, 'b, A: 'a, B: 'b, C>(&'a A, &'b mut B, C);
|
||||
|
||||
let a = 5;
|
||||
let mut b = 6;
|
||||
let c = 7;
|
||||
@@ -104,6 +104,27 @@ fn test_named_tuple() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_de_named_tuple() {
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive_deserialize]
|
||||
struct NamedTuple<A, B, C>(A, B, C);
|
||||
|
||||
assert_eq!(
|
||||
json::from_str("[1,2,3]").unwrap(),
|
||||
NamedTuple(1, 2, 3)
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
json::from_str("[1,2,3]").unwrap(),
|
||||
Value::Array(vec![
|
||||
Value::I64(1),
|
||||
Value::I64(2),
|
||||
Value::I64(3),
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_named_map() {
|
||||
let a = 5;
|
||||
|
||||
Reference in New Issue
Block a user