Skip to content

Instantly share code, notes, and snippets.

@nixpulvis
Last active February 23, 2017 08:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nixpulvis/8208eb183e8441237be1afdef849556e to your computer and use it in GitHub Desktop.
Save nixpulvis/8208eb183e8441237be1afdef849556e to your computer and use it in GitHub Desktop.
//! ```cargo
//! [dependencies]
//! serde = { git = "https://github.com/nixpulvis/serde.git" }
//! serde_json = { git = "https://github.com/nixpulvis/json.git" }
//! ```
extern crate serde;
extern crate serde_json as json;
use serde::de;
use json::error::Error;
#[derive(Debug)]
struct Foo(u64);
impl de::Deserialize for Foo {
fn deserialize<D>(deserializer: &mut D) -> Result<Foo, D::Error>
where D: de::Deserializer
{
Ok(Foo(1))
}
}
fn main() {
let foo: Foo = json::from_str::<Foo>("test").unwrap();
println!("{:?}", foo);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment