Skip to content

Commit e8df2a4

Browse files
committed
remove option.insert_with
`option.insert` covers both needs anyway, `insert_with` is redundant.
1 parent 9b90e17 commit e8df2a4

File tree

1 file changed

+1
-19
lines changed

1 file changed

+1
-19
lines changed

library/core/src/option.rs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -581,25 +581,7 @@ impl<T> Option<T> {
581581
#[inline]
582582
#[unstable(feature = "option_insert", reason = "new API", issue = "none")]
583583
pub fn insert(&mut self, v: T) -> &mut T {
584-
self.insert_with(|| v)
585-
}
586-
587-
/// Inserts a value computed from `f` into the option, then returns a
588-
/// mutable reference to the contained value.
589-
///
590-
/// # Example
591-
///
592-
/// ```
593-
/// #![feature(option_insert)]
594-
///
595-
/// let mut o = None;
596-
/// let v = o.insert_with(|| 3);
597-
/// assert_eq!(*v, 3);
598-
/// ```
599-
#[inline]
600-
#[unstable(feature = "option_insert", reason = "new API", issue = "none")]
601-
pub fn insert_with<F: FnOnce() -> T>(&mut self, f: F) -> &mut T {
602-
*self = Some(f());
584+
*self = Some(v);
603585

604586
match *self {
605587
Some(ref mut v) => v,

0 commit comments

Comments
 (0)