Skip to content

Commit

Permalink
Rename bool's then to to_option
Browse files Browse the repository at this point in the history
  • Loading branch information
varkor committed Dec 6, 2019
1 parent d0126e8 commit 51901ee
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/libcore/bool.rs
Expand Up @@ -9,12 +9,12 @@ impl bool {
/// ```
/// #![feature(bool_to_option)]
///
/// assert_eq!(false.then(0), None);
/// assert_eq!(true.then(0), Some(0));
/// assert_eq!(false.to_option(0), None);
/// assert_eq!(true.to_option(0), Some(0));
/// ```
#[unstable(feature = "bool_to_option", issue = "64260")]
#[inline]
pub fn then<T>(self, t: T) -> Option<T> {
pub fn to_option<T>(self, t: T) -> Option<T> {
if self {
Some(t)
} else {
Expand All @@ -29,12 +29,12 @@ impl bool {
/// ```
/// #![feature(bool_to_option)]
///
/// assert_eq!(false.then_with(|| 0), None);
/// assert_eq!(true.then_with(|| 0), Some(0));
/// assert_eq!(false.to_option_with(|| 0), None);
/// assert_eq!(true.to_option_with(|| 0), Some(0));
/// ```
#[unstable(feature = "bool_to_option", issue = "64260")]
#[inline]
pub fn then_with<T, F: FnOnce() -> T>(self, f: F) -> Option<T> {
pub fn to_option_with<T, F: FnOnce() -> T>(self, f: F) -> Option<T> {
if self {
Some(f())
} else {
Expand Down

0 comments on commit 51901ee

Please sign in to comment.