diff options
| author | Canop <cano.petrole@gmail.com> | 2020-10-01 13:24:33 +0200 |
|---|---|---|
| committer | Canop <cano.petrole@gmail.com> | 2020-10-23 11:41:19 +0200 |
| commit | e8df2a426959fa3ff4f65eae85e618394bf27e28 (patch) | |
| tree | 2bba9cda614fb65a42054e315e2b92dedce7985f | |
| parent | 9b90e1762e6cb21baa504a27530b9aa404fbe3ac (diff) | |
| download | rust-e8df2a426959fa3ff4f65eae85e618394bf27e28.tar.gz rust-e8df2a426959fa3ff4f65eae85e618394bf27e28.zip | |
remove `option.insert_with`
`option.insert` covers both needs anyway, `insert_with` is redundant.
| -rw-r--r-- | library/core/src/option.rs | 20 |
1 files changed, 1 insertions, 19 deletions
diff --git a/library/core/src/option.rs b/library/core/src/option.rs index 394be746ec2..64541da300e 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -581,25 +581,7 @@ impl<T> Option<T> { #[inline] #[unstable(feature = "option_insert", reason = "new API", issue = "none")] pub fn insert(&mut self, v: T) -> &mut T { - self.insert_with(|| v) - } - - /// Inserts a value computed from `f` into the option, then returns a - /// mutable reference to the contained value. - /// - /// # Example - /// - /// ``` - /// #![feature(option_insert)] - /// - /// let mut o = None; - /// let v = o.insert_with(|| 3); - /// assert_eq!(*v, 3); - /// ``` - #[inline] - #[unstable(feature = "option_insert", reason = "new API", issue = "none")] - pub fn insert_with<F: FnOnce() -> T>(&mut self, f: F) -> &mut T { - *self = Some(f()); + *self = Some(v); match *self { Some(ref mut v) => v, |
