stabilize Option::as_(mut_)slice · rust-lang/rust@702da3b (original) (raw)

`@@ -743,8 +743,6 @@ impl Option {

`

743

743

`/// # Examples

`

744

744

`///

`

745

745

```` /// ```rust


`746`

``

`-

/// #![feature(option_as_slice)]

`

`747`

``

`-

///

`

`748`

`746`

`/// assert_eq!(

`

`749`

`747`

`/// [Some(1234).as_slice(), None.as_slice()],

`

`750`

`748`

`/// [&[1234][..], &[][..]],

`

`@@ -755,15 +753,13 @@ impl<T> Option<T> {

`

`755`

`753`

`` /// borrowing) [`[_]::first`](slice::first):

``

`756`

`754`

`///

`

`757`

`755`

```` /// ```rust

758

``

`-

/// #![feature(option_as_slice)]

`

759

``

`-

///

`

760

756

`/// for i in [Some(1234_u16), None] {

`

761

757

`/// assert_eq!(i.as_ref(), i.as_slice().first());

`

762

758

`/// }

`

763

759

```` /// ```


`764`

`760`

`#[inline]

`

`765`

`761`

`#[must_use]

`

`766`

``

`-

#[unstable(feature = "option_as_slice", issue = "108545")]

`

``

`762`

`+

#[stable(feature = "option_as_slice", since = "CURRENT_RUSTC_VERSION")]

`

`767`

`763`

`pub fn as_slice(&self) -> &[T] {

`

`768`

`764`

`` // SAFETY: When the `Option` is `Some`, we're using the actual pointer

``

`769`

`765`

`// to the payload, with a length of 1, so this is equivalent to

`

`@@ -794,8 +790,6 @@ impl<T> Option<T> {

`

`794`

`790`

`/// # Examples

`

`795`

`791`

`///

`

`796`

`792`

```` /// ```rust

797

``

`-

/// #![feature(option_as_slice)]

`

798

``

`-

///

`

799

793

`/// assert_eq!(

`

800

794

`/// [Some(1234).as_mut_slice(), None.as_mut_slice()],

`

801

795

`/// [&mut [1234][..], &mut [][..]],

`

`@@ -806,8 +800,6 @@ impl Option {

`

806

800

`` /// our original Option:

``

807

801

`///

`

808

802

```` /// ```rust


`809`

``

`-

/// #![feature(option_as_slice)]

`

`810`

``

`-

///

`

`811`

`803`

`/// let mut x = Some(1234);

`

`812`

`804`

`/// x.as_mut_slice()[0] += 1;

`

`813`

`805`

`/// assert_eq!(x, Some(1235));

`

`@@ -817,13 +809,11 @@ impl<T> Option<T> {

`

`817`

`809`

`` /// is [`[_]::first_mut`](slice::first_mut):

``

`818`

`810`

`///

`

`819`

`811`

```` /// ```rust

820

``

`-

/// #![feature(option_as_slice)]

`

821

``

`-

///

`

822

812

`/// assert_eq!(Some(123).as_mut_slice().first_mut(), Some(&mut 123))

`

823

813

```` /// ```

````

824

814

`#[inline]

`

825

815

`#[must_use]

`

826

``

`-

#[unstable(feature = "option_as_slice", issue = "108545")]

`

``

816

`+

#[stable(feature = "option_as_slice", since = "CURRENT_RUSTC_VERSION")]

`

827

817

`pub fn as_mut_slice(&mut self) -> &mut [T] {

`

828

818

`` // SAFETY: When the Option is Some, we're using the actual pointer

``

829

819

`// to the payload, with a length of 1, so this is equivalent to

`