diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-10-05 19:24:33 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-05 19:24:33 +0200 |
| commit | 864e5d8d94e7a6aa5ed1780ff3846ceae548ee5e (patch) | |
| tree | f10e39f9252131a00add1e26d1ee39186319d67a | |
| parent | cf9fd95b1c278da6069546f305925e6250b19842 (diff) | |
| parent | 702da3b89c8c586fea9d257779e0e75562efa552 (diff) | |
| download | rust-864e5d8d94e7a6aa5ed1780ff3846ceae548ee5e.tar.gz rust-864e5d8d94e7a6aa5ed1780ff3846ceae548ee5e.zip | |
Rollup merge of #116220 - llogiq:stabilize-option-as-slice, r=BurntSushi
stabilize `Option::as_`(`mut_`)`slice` This is the stabilization to #108545. Thanks to everyone who helped getting this into Rust proper.
| -rw-r--r-- | compiler/rustc_hir_typeck/src/lib.rs | 1 | ||||
| -rw-r--r-- | library/core/src/option.rs | 14 |
2 files changed, 2 insertions, 13 deletions
diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs index 6873382c4ac..cd6adb345e7 100644 --- a/compiler/rustc_hir_typeck/src/lib.rs +++ b/compiler/rustc_hir_typeck/src/lib.rs @@ -5,7 +5,6 @@ #![feature(box_patterns)] #![feature(min_specialization)] #![feature(control_flow_enum)] -#![feature(option_as_slice)] #![recursion_limit = "256"] #[macro_use] diff --git a/library/core/src/option.rs b/library/core/src/option.rs index f2909a81d49..9899014e85a 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -743,8 +743,6 @@ impl<T> Option<T> { /// # Examples /// /// ```rust - /// #![feature(option_as_slice)] - /// /// assert_eq!( /// [Some(1234).as_slice(), None.as_slice()], /// [&[1234][..], &[][..]], @@ -755,15 +753,13 @@ impl<T> Option<T> { /// borrowing) [`[_]::first`](slice::first): /// /// ```rust - /// #![feature(option_as_slice)] - /// /// for i in [Some(1234_u16), None] { /// assert_eq!(i.as_ref(), i.as_slice().first()); /// } /// ``` #[inline] #[must_use] - #[unstable(feature = "option_as_slice", issue = "108545")] + #[stable(feature = "option_as_slice", since = "CURRENT_RUSTC_VERSION")] pub fn as_slice(&self) -> &[T] { // SAFETY: When the `Option` is `Some`, we're using the actual pointer // to the payload, with a length of 1, so this is equivalent to @@ -794,8 +790,6 @@ impl<T> Option<T> { /// # Examples /// /// ```rust - /// #![feature(option_as_slice)] - /// /// assert_eq!( /// [Some(1234).as_mut_slice(), None.as_mut_slice()], /// [&mut [1234][..], &mut [][..]], @@ -806,8 +800,6 @@ impl<T> Option<T> { /// our original `Option`: /// /// ```rust - /// #![feature(option_as_slice)] - /// /// let mut x = Some(1234); /// x.as_mut_slice()[0] += 1; /// assert_eq!(x, Some(1235)); @@ -817,13 +809,11 @@ impl<T> Option<T> { /// is [`[_]::first_mut`](slice::first_mut): /// /// ```rust - /// #![feature(option_as_slice)] - /// /// assert_eq!(Some(123).as_mut_slice().first_mut(), Some(&mut 123)) /// ``` #[inline] #[must_use] - #[unstable(feature = "option_as_slice", issue = "108545")] + #[stable(feature = "option_as_slice", since = "CURRENT_RUSTC_VERSION")] pub fn as_mut_slice(&mut self) -> &mut [T] { // SAFETY: When the `Option` is `Some`, we're using the actual pointer // to the payload, with a length of 1, so this is equivalent to |
