diff options
| author | varkor <github@varkor.com> | 2019-12-06 12:18:32 +0000 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2019-12-06 12:24:54 +0000 |
| commit | 9f1269f23c5f0c1c6a53118b51cf52415ac0bb1c (patch) | |
| tree | a7b18394302ae6733495354966b81188380a5ea8 /src/libcore/bool.rs | |
| parent | 8579fe6fc3a28e5a7cbd95ada3a3305a73782c82 (diff) | |
| download | rust-9f1269f23c5f0c1c6a53118b51cf52415ac0bb1c.tar.gz rust-9f1269f23c5f0c1c6a53118b51cf52415ac0bb1c.zip | |
Rename to `then_some` and `then`
Diffstat (limited to 'src/libcore/bool.rs')
| -rw-r--r-- | src/libcore/bool.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/libcore/bool.rs b/src/libcore/bool.rs index aa1ba7affc1..1b3c254a05f 100644 --- a/src/libcore/bool.rs +++ b/src/libcore/bool.rs @@ -9,12 +9,12 @@ impl bool { /// ``` /// #![feature(bool_to_option)] /// - /// assert_eq!(false.to_option(0), None); - /// assert_eq!(true.to_option(0), Some(0)); + /// assert_eq!(false.then_some(0), None); + /// assert_eq!(true.then_some(0), Some(0)); /// ``` #[unstable(feature = "bool_to_option", issue = "64260")] #[inline] - pub fn to_option<T>(self, t: T) -> Option<T> { + pub fn then_some<T>(self, t: T) -> Option<T> { if self { Some(t) } else { @@ -29,12 +29,12 @@ impl bool { /// ``` /// #![feature(bool_to_option)] /// - /// assert_eq!(false.to_option_with(|| 0), None); - /// assert_eq!(true.to_option_with(|| 0), Some(0)); + /// assert_eq!(false.then(|| 0), None); + /// assert_eq!(true.then(|| 0), Some(0)); /// ``` #[unstable(feature = "bool_to_option", issue = "64260")] #[inline] - pub fn to_option_with<T, F: FnOnce() -> T>(self, f: F) -> Option<T> { + pub fn then<T, F: FnOnce() -> T>(self, f: F) -> Option<T> { if self { Some(f()) } else { |
