Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions library/core/src/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1842,6 +1842,20 @@ impl<T> Option<T> {
mem::replace(self, None)
}

/// Clear the value of the option.
///
/// # Examples
///
/// ```
/// let mut x = Some(2);
/// x.clear();
/// assert_eq!(x, None);
/// ```
#[inline(always)]
pub const fn clear(&mut self) {
let _ = self.take();
}

/// Takes the value out of the option, but only if the predicate evaluates to
/// `true` on a mutable reference to the value.
///
Expand Down
Loading