Tracking Issue for Vec::recycle (original) (raw)
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 =
for<'a> TransmuteFrom<&'a MaybeUninit, { Assume::SAFETY }>
where
T: for<'a> TransmuteFrom<&'a MaybeUninit, { Assume::SAFETY }>;
impl Vec { #[feature(vec_recycle)] pub fn recycle(self) -> Vec where U: Recyclable; }
Steps / History
- ACP: Vec::recycle libs-team#674
- Implementation: #...
- Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
- Make sure that we don't unintentionally create reliance on this as workaround for lack of stable TransmuteFrom, when this stabilizes.