Open
Description
Feature gate: #![feature(const_destruct)]
This is a tracking issue for const_destruct
, which enables the naming of the Destruct
trait and its use in ~const
bounds to allow dropping values in const contexts.
Public API
pub trait Destruct { }
Steps / History
- Implementation: It was already implemented, but it's getting a new feature gate in Implement
~const Destruct
effect goal in the new solver #132329. - Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
- Do we want to allow
~const
bounds onconst Drop
impls?
I think we do, and sorely need them for const drop to ever be useful. See my justification in #132329 (comment). We want to be able to implement a conditional drop impl like:
struct DropAndCall<F: Fn()>(F);
impl<F> const Drop for DropAndCall<F>
where
F: ~const Fn(),
{
fn drop(&mut self) {
(self.0)(); // This should be allowed.
}
}
This is what is implemented on nightly.
Footnotes
Metadata
Metadata
Assignees
Labels
Category: An issue tracking the progress of sth. like the implementation of an RFC`#![feature(const_trait_impl)]`Project group: Const traitsRelevant to the language team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.