feat(tvix/serde): add newtype & tuple deserialisation
Only missing enums at this point, but they're a bit of a beast. Change-Id: I4ad47c034851f9a8794c81f39a5149a8ac1826e8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7716 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de> Autosubmit: tazjin <tazjin@tvl.su>
This commit is contained in:
parent
0c17718dd1
commit
0e88eb83ef
2 changed files with 27 additions and 10 deletions
|
|
@ -80,3 +80,18 @@ fn deserialize_struct() {
|
|||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn deserialize_newtype() {
|
||||
#[derive(Debug, Deserialize, PartialEq)]
|
||||
struct Number(usize);
|
||||
|
||||
let result: Number = from_str("42").expect("should deserialize");
|
||||
assert_eq!(result, Number(42));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn deserialize_tuple() {
|
||||
let result: (String, usize) = from_str(r#" [ "foo" 42 ] "#).expect("should deserialize");
|
||||
assert_eq!(result, ("foo".into(), 42));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue