Rollup merge of #148757 - nxsaken:const_mem_take, r=scottmcm

Constify `mem::take`

Feature: `const_default` (rust-lang/rust#143894)
This commit is contained in:
Stuart Cook
2025-11-17 16:41:02 +11:00
committed by GitHub
+2 -1
View File
@@ -808,7 +808,8 @@ pub const fn swap<T>(x: &mut T, y: &mut T) {
/// ```
#[inline]
#[stable(feature = "mem_take", since = "1.40.0")]
pub fn take<T: Default>(dest: &mut T) -> T {
#[rustc_const_unstable(feature = "const_default", issue = "143894")]
pub const fn take<T: [const] Default>(dest: &mut T) -> T {
replace(dest, T::default())
}