This commit is contained in:
Lzu Tao 2019-08-19 05:41:47 +00:00
parent 50ecd595a6
commit 41eba2f26a
2 changed files with 8 additions and 0 deletions

View File

@ -19,3 +19,7 @@ pub fn foo() -> Option<String> {
let x = Some(String::from("hello"));
Some("hello".to_owned()).and_then(|s| Some(format!("{}{}", s, x?)))
}
pub fn example2(x: bool) -> Option<&'static str> {
Some("a").and_then(|s| Some(if x { s } else { return None }))
}

View File

@ -19,3 +19,7 @@ pub fn foo() -> Option<String> {
let x = Some(String::from("hello"));
Some("hello".to_owned()).and_then(|s| Some(format!("{}{}", s, x?)))
}
pub fn example2(x: bool) -> Option<&'static str> {
Some("a").and_then(|s| Some(if x { s } else { return None }))
}