Skip to content

Tracking Issue for Vec::recycle #148227

@llogiq

Description

@llogiq

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

  • None yet.

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

Metadata

Metadata

Assignees

Labels

C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libsRelevant to the library team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions