Rollup merge of #129087 - slanterns:option_get_or_insert_default, r=dtolnay

Stabilize `option_get_or_insert_default`

Closes: https://github.com/rust-lang/rust/issues/82901.

`@rustbot` label: +T-libs-api

r? libs-api
This commit is contained in:
Matthias Krüger 2024-09-27 19:07:58 +02:00 committed by GitHub
commit e76eb96a00
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 1 additions and 4 deletions

View File

@ -3,7 +3,6 @@
#![feature(iter_intersperse)] #![feature(iter_intersperse)]
#![feature(let_chains)] #![feature(let_chains)]
#![feature(map_many_mut)] #![feature(map_many_mut)]
#![feature(option_get_or_insert_default)]
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![warn(unreachable_pub)] #![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end

View File

@ -1639,8 +1639,6 @@ impl<T> Option<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(option_get_or_insert_default)]
///
/// let mut x = None; /// let mut x = None;
/// ///
/// { /// {
@ -1653,7 +1651,7 @@ impl<T> Option<T> {
/// assert_eq!(x, Some(7)); /// assert_eq!(x, Some(7));
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "option_get_or_insert_default", issue = "82901")] #[stable(feature = "option_get_or_insert_default", since = "CURRENT_RUSTC_VERSION")]
pub fn get_or_insert_default(&mut self) -> &mut T pub fn get_or_insert_default(&mut self) -> &mut T
where where
T: Default, T: Default,