Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 5 pull requests #116455

Merged
merged 13 commits into from
Oct 5, 2023
Merged
Next Next commit
stabilize Option::as_(mut_)slice
  • Loading branch information
llogiq committed Sep 28, 2023
commit 702da3b89c8c586fea9d257779e0e75562efa552
1 change: 0 additions & 1 deletion compiler/rustc_hir_typeck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#![feature(box_patterns)]
#![feature(min_specialization)]
#![feature(control_flow_enum)]
#![feature(option_as_slice)]
#![recursion_limit = "256"]

#[macro_use]
Expand Down
14 changes: 2 additions & 12 deletions library/core/src/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,8 +743,6 @@ impl<T> Option<T> {
/// # Examples
///
/// ```rust
/// #![feature(option_as_slice)]
///
/// assert_eq!(
/// [Some(1234).as_slice(), None.as_slice()],
/// [&[1234][..], &[][..]],
Expand All @@ -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
Expand Down Expand Up @@ -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 [][..]],
Expand All @@ -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));
Expand All @@ -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
Expand Down
Loading