Skip to content

Commit

Permalink
Rollup merge of #86593 - jhpratt:stabilize-const_slice_first_last, r=…
Browse files Browse the repository at this point in the history
…m-ou-se

Partially stabilize `const_slice_first_last`

This stabilizes the non-`mut` methods of `const_slice_first_last` as `const`. These methods are trivial to implement and have no blockers that I am aware of.

`@rustbot` label +A-const-fn +S-waiting-on-review +T-libs-api
  • Loading branch information
JohnTitor committed Aug 2, 2021
2 parents 1176d30 + 9854d30 commit 77d5683
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl<T> [T] {
/// assert_eq!(None, w.first());
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_slice_first_last", issue = "83570")]
#[rustc_const_stable(feature = "const_slice_first_last_not_mut", since = "1.56.0")]
#[inline]
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
Expand Down Expand Up @@ -177,7 +177,7 @@ impl<T> [T] {
/// }
/// ```
#[stable(feature = "slice_splits", since = "1.5.0")]
#[rustc_const_unstable(feature = "const_slice_first_last", issue = "83570")]
#[rustc_const_stable(feature = "const_slice_first_last_not_mut", since = "1.56.0")]
#[inline]
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
Expand Down Expand Up @@ -217,7 +217,7 @@ impl<T> [T] {
/// }
/// ```
#[stable(feature = "slice_splits", since = "1.5.0")]
#[rustc_const_unstable(feature = "const_slice_first_last", issue = "83570")]
#[rustc_const_stable(feature = "const_slice_first_last_not_mut", since = "1.56.0")]
#[inline]
pub const fn split_last(&self) -> Option<(&T, &[T])> {
if let [init @ .., last] = self { Some((last, init)) } else { None }
Expand Down Expand Up @@ -256,7 +256,7 @@ impl<T> [T] {
/// assert_eq!(None, w.last());
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_slice_first_last", issue = "83570")]
#[rustc_const_stable(feature = "const_slice_first_last_not_mut", since = "1.56.0")]
#[inline]
pub const fn last(&self) -> Option<&T> {
if let [.., last] = self { Some(last) } else { None }
Expand Down

0 comments on commit 77d5683

Please sign in to comment.