Skip to content

Instantly share code, notes, and snippets.

@pzol
Last active August 29, 2015 14:07
Show Gist options
  • Save pzol/4774c407651706b5bc1d to your computer and use it in GitHub Desktop.
Save pzol/4774c407651706b5bc1d to your computer and use it in GitHub Desktop.
struct FooResult {
good: Option<String>,
bad: Option<String>
}
impl FooResult {
fn new(result: Result<String, String>) -> FooResult {
match result {
Ok(ok) => FooResult { good: Some(ok), bad: None },
Err(err) => FooResult { good: None, bad: Some(err) }
}
}
}
#[test]
fn result() {
let r : Result<String, String> = Ok("foobar".to_string());
let foo = FooResult::new(r);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment