Skip to content

Commit

Permalink
Stabilize <[T]>::get_many_mut()
Browse files Browse the repository at this point in the history
  • Loading branch information
ChayimFriedman2 committed Jul 28, 2024
1 parent d618ebc commit 3b9517d
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 15 deletions.
2 changes: 1 addition & 1 deletion library/alloc/src/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub use core::slice::ArrayChunksMut;
pub use core::slice::ArrayWindows;
#[stable(feature = "inherent_ascii_escape", since = "1.60.0")]
pub use core::slice::EscapeAscii;
#[unstable(feature = "get_many_mut", issue = "104642")]
#[stable(feature = "get_many_mut", since = "CURRENT_RUSTC_VERSION")]
pub use core::slice::GetManyMutError;
#[stable(feature = "slice_get_slice", since = "1.28.0")]
pub use core::slice::SliceIndex;
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1076,5 +1076,5 @@ impl Error for crate::time::TryFromFloatSecsError {}
#[stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")]
impl Error for crate::ffi::FromBytesUntilNulError {}

#[unstable(feature = "get_many_mut", issue = "104642")]
#[stable(feature = "get_many_mut", since = "CURRENT_RUSTC_VERSION")]
impl<const N: usize> Error for crate::slice::GetManyMutError<N> {}
16 changes: 5 additions & 11 deletions library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4448,8 +4448,6 @@ impl<T> [T] {
/// # Examples
///
/// ```
/// #![feature(get_many_mut)]
///
/// let x = &mut [1, 2, 4];
///
/// unsafe {
Expand All @@ -4462,7 +4460,7 @@ impl<T> [T] {
///
/// [`get_many_mut`]: slice::get_many_mut
/// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
#[unstable(feature = "get_many_mut", issue = "104642")]
#[stable(feature = "get_many_mut", since = "CURRENT_RUSTC_VERSION")]
#[inline]
pub unsafe fn get_many_unchecked_mut<const N: usize>(
&mut self,
Expand Down Expand Up @@ -4495,16 +4493,14 @@ impl<T> [T] {
/// # Examples
///
/// ```
/// #![feature(get_many_mut)]
///
/// let v = &mut [1, 2, 3];
/// if let Ok([a, b]) = v.get_many_mut(&[0, 2]) {
/// *a = 413;
/// *b = 612;
/// }
/// assert_eq!(v, &[413, 2, 612]);
/// ```
#[unstable(feature = "get_many_mut", issue = "104642")]
#[stable(feature = "get_many_mut", since = "CURRENT_RUSTC_VERSION")]
#[inline]
pub fn get_many_mut<const N: usize>(
&mut self,
Expand Down Expand Up @@ -4886,27 +4882,25 @@ fn get_many_check_valid<const N: usize>(indices: &[usize; N], len: usize) -> boo
/// # Examples
///
/// ```
/// #![feature(get_many_mut)]
///
/// let v = &mut [1, 2, 3];
/// assert!(v.get_many_mut(&[0, 999]).is_err());
/// assert!(v.get_many_mut(&[1, 1]).is_err());
/// ```
#[unstable(feature = "get_many_mut", issue = "104642")]
#[stable(feature = "get_many_mut", since = "CURRENT_RUSTC_VERSION")]
// NB: The N and the private field here is there to be forward-compatible with
// adding more details to the error type at a later point
pub struct GetManyMutError<const N: usize> {
_private: (),
}

#[unstable(feature = "get_many_mut", issue = "104642")]
#[stable(feature = "get_many_mut", since = "CURRENT_RUSTC_VERSION")]
impl<const N: usize> fmt::Debug for GetManyMutError<N> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("GetManyMutError").finish_non_exhaustive()
}
}

#[unstable(feature = "get_many_mut", issue = "104642")]
#[stable(feature = "get_many_mut", since = "CURRENT_RUSTC_VERSION")]
impl<const N: usize> fmt::Display for GetManyMutError<N> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt("an index is out of bounds or appeared multiple times in the array", f)
Expand Down
1 change: 0 additions & 1 deletion library/core/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@
#![feature(error_generic_member_access)]
#![feature(trait_upcasting)]
#![feature(is_ascii_octdigit)]
#![feature(get_many_mut)]
#![feature(iter_map_windows)]
#![allow(internal_features)]
#![deny(unsafe_op_in_unsafe_fn)]
Expand Down
1 change: 0 additions & 1 deletion library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,6 @@
#![feature(custom_test_frameworks)]
#![feature(edition_panic)]
#![feature(format_args_nl)]
#![feature(get_many_mut)]
#![feature(log_syntax)]
#![feature(test)]
#![feature(trace_macros)]
Expand Down

0 comments on commit 3b9517d

Please sign in to comment.