File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 296296//! }
297297//! ```
298298//!
299+ //! ## Modifying an [`Option`] in-place
300+ //!
301+ //! These methods return a mutable reference to the contained value of a
302+ //! [`Some`].
303+ //!
304+ //! * [`insert`] inserts a value, dropping any old contents
305+ //! * [`get_or_insert`] gets the current value, inserting a provided
306+ //! default value if it is [`None`]
307+ //! * [`get_or_insert_default`] gets the current value, inserting the
308+ //! default value of type `T` if it is [`None`]
309+ //! * [`get_or_insert_with`] gets the current value, inserting a default
310+ //! computed by the provided function if it is [`None`]
311+ //!
312+ //! [`insert`]: Option::insert
313+ //! [`get_or_insert`]: Option::get_or_insert
314+ //! [`get_or_insert_default`]: Option::get_or_insert_default
315+ //! [`get_or_insert_with`]: Option::get_or_insert_with
316+ //!
317+ //! These methods transfer ownership of the [`Option`].
318+ //!
319+ //! * [`take`] takes ownership of the [`Option`], including any contained
320+ //! value, replacing it with [`None`]
321+ //! * [`replace`] takes ownership of the [`Option`], including any
322+ //! contained value, replacing it with a [`Some`] containing the provided
323+ //! value
324+ //!
325+ //! [`take`]: Option::take
326+ //! [`replace`]: Option::replace
327+ //!
299328//! # Examples
300329//!
301330//! Basic pattern matching on [`Option`]:
You can’t perform that action at this time.
0 commit comments