From 41eba2f26aa0bb45148d37e9696b73322f8d6ca0 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Mon, 19 Aug 2019 05:41:47 +0000 Subject: [PATCH] Add test --- tests/ui/option_and_then_some.fixed | 4 ++++ tests/ui/option_and_then_some.rs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/tests/ui/option_and_then_some.fixed b/tests/ui/option_and_then_some.fixed index 852f48879a3..035bc1e5465 100644 --- a/tests/ui/option_and_then_some.fixed +++ b/tests/ui/option_and_then_some.fixed @@ -19,3 +19,7 @@ pub fn foo() -> Option { 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 })) +} diff --git a/tests/ui/option_and_then_some.rs b/tests/ui/option_and_then_some.rs index aebc66374a5..d49da7813c6 100644 --- a/tests/ui/option_and_then_some.rs +++ b/tests/ui/option_and_then_some.rs @@ -19,3 +19,7 @@ pub fn foo() -> Option { 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 })) +}