-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cc @bugarela ## `Option` ```rust use serde::Deserialize; use serde_json::json; use itf::de::{self, As}; #[derive(Debug, PartialEq, Deserialize)] struct FooOption { #[serde(with = "As::<de::Option::<_>>")] foo: Option<u64>, } let some_itf = json!({ "foo": { "tag": "Some", "value": 42, } }); let some_foo = itf::from_value::<FooOption>(some_itf).unwrap(); assert_eq!(some_foo, FooOption { foo: Some(42) }); let none_itf = json!({ "foo": { "tag": "None", "value": {}, } }); let none_foo = itf::from_value::<FooOption>(none_itf).unwrap(); assert_eq!(none_foo, FooOption { foo: None }); ``` ## `Result` ```rust use serde::Deserialize; use serde_json::json; use itf::de::{self, As}; #[derive(Debug, PartialEq, Deserialize)] struct FooResult { #[serde(with = "As::<de::Result::<_, _>>")] foo: Result<u64, u64>, } let ok_itf = json!({ "foo": { "tag": "Ok", "value": 42, } }); let ok = itf::from_value::<FooResult>(ok_itf).unwrap(); assert_eq!(ok.foo, Ok(42)); let err_itf = json!({ "foo": { "tag": "Err", "value": 42, } }); let err = itf::from_value::<FooResult>(err_itf).unwrap(); assert_eq!(err.foo, Err(42)); ```
- Loading branch information
Showing
9 changed files
with
227 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
use std::fmt; | ||
|
||
/// Error type for deserialization. | ||
#[derive(Debug)] | ||
pub enum Error { | ||
Custom(String), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
//! Error type for the library. | ||
/// Error type for the library. | ||
#[derive(Debug)] | ||
pub enum Error { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
//! Infrastructure for running a trace against a concrete implementation. | ||
use crate::Trace; | ||
|
||
pub trait Runner { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
//! Defines an ITF trace. | ||
use std::collections::BTreeMap; | ||
|
||
use serde::de::DeserializeOwned; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters