Feature gate: #![feature(const_swap)]
This is a tracking issue for making the functions mem::swap and ptr::swap[_nonoverlapping] and some other swap related functions const fn.
Public API
mod ptr {
pub const unsafe fn swap<T>(x: *mut T, y: *mut T);
}
mod mem {
pub const fn swap<T>(x: &mut T, y: &mut T);
}
impl<T> [T] {
pub const fn swap(&mut self, a: usize, b: usize);
}
impl<T: ?Sized> *mut T {
pub const unsafe fn swap(self, with: *mut T);
}
impl <T> NonNull<T> {
pub const unsafe fn swap(self, with: NonNull<T>);
}
Steps / History
Unresolved Questions
Feature gate:
#![feature(const_swap)]This is a tracking issue for making the functions
mem::swapandptr::swap[_nonoverlapping]and some other swap related functionsconst fn.Public API
Steps / History
memandptr): Constifycopyrelated functions #83091[T]and*mut T )Extend the const swap feature #90644NonNullmethods stabilized,constness moved to this gate Stabilizenon_null_convenience#124498Unresolved Questions