Rollup merge of #142205 - paolobarbolini:const_swap_with_slice-impl, r=Mark-Simulacrum
Mark `slice::swap_with_slice` unstably const Tracking issue rust-lang/rust#142204
This commit is contained in:
@@ -3974,8 +3974,9 @@ impl<T> [T] {
|
||||
///
|
||||
/// [`split_at_mut`]: slice::split_at_mut
|
||||
#[stable(feature = "swap_with_slice", since = "1.27.0")]
|
||||
#[rustc_const_unstable(feature = "const_swap_with_slice", issue = "142204")]
|
||||
#[track_caller]
|
||||
pub fn swap_with_slice(&mut self, other: &mut [T]) {
|
||||
pub const fn swap_with_slice(&mut self, other: &mut [T]) {
|
||||
assert!(self.len() == other.len(), "destination and source slices have different lengths");
|
||||
// SAFETY: `self` is valid for `self.len()` elements by definition, and `src` was
|
||||
// checked to have the same length. The slices cannot overlap because
|
||||
|
||||
Reference in New Issue
Block a user