Feature gate: #![feature(vec_recycle)]
This is a tracking issue for the Vec::recycle method, which allows reusing a Vec in a loop even if the lifetime unification would otherwise disallow it.
Public API
// in alloc::vec
#![feature(transmutability)]
#![feature(trait_alias)]
use std::mem::{Assume, MaybeUninit, TransmuteFrom};
/// Implemented if the size and alignment `T` and `Self` are both equal.
trait Recyclable<T> =
for<'a> TransmuteFrom<&'a MaybeUninit<T>, { Assume::SAFETY }>
where
T: for<'a> TransmuteFrom<&'a MaybeUninit<Self>, { Assume::SAFETY }>;
impl<T> Vec<T> {
#[feature(vec_recycle)]
pub fn recycle<U>(self) -> Vec<U> where U: Recyclable<T>;
}
Steps / History
Unresolved Questions
- Make sure that we don't unintentionally create reliance on this as workaround for lack of stable TransmuteFrom, when this stabilizes.
Feature gate:
#![feature(vec_recycle)]This is a tracking issue for the
Vec::recyclemethod, which allows reusing aVecin a loop even if the lifetime unification would otherwise disallow it.Public API
Steps / History
Unresolved Questions
Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩