Skip to content

Instantly share code, notes, and snippets.

@MarkJr94
Created November 1, 2013 00:38
Show Gist options
  • Save MarkJr94/7259482 to your computer and use it in GitHub Desktop.
Save MarkJr94/7259482 to your computer and use it in GitHub Desktop.
pub trait FromJson {
fn from_json(j :&Json) -> Result<Self, ValueError>;
}
impl<T: FromJson> FromJson for Option<T> {
fn from_json(j: &Json) -> Result<Option<T>, ValueError> {
match *j {
Null => Ok(None),
otherwise => {
let t = FromJson::from_json(&otherwise);
match t {
Ok(thing) => Ok(Some(thing)),
Err(v) => Err(v)
}
}
}
}
}
// util/json.rs:214:12: 214:21 error: unreachable pattern
// util/json.rs:214 otherwise => {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment