-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-unimplementedStatus: The feature has not been implemented.Status: The feature has not been implemented.T-libs-apiRelevant to the library API 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.
Description
Feature gate: #![feature(drop_guard)]
This is a tracking issue for the core::mem::DropGuard
API: a helper type that makes it easy to create impl Drop
destructors inline.
Public API
#![feature(drop_guard)]
use std::mem::DropGuard;
{
// Create a new guard around a string that will
// print its value when dropped.
let s = String::from("Chashu likes tuna");
let mut s = DropGuard::new(s, |s| println!("{s}"));
// Modify the string contained in the guard.
s.push_str("!!!");
// The guard will be dropped here, printing:
// "Chashu likes tuna!!!"
}
Steps / History
(Remember to update the S-tracking-*
label when checking boxes.)
- ACP: ACP: Add core::mem::WithDrop to associate a custom drop fn with some data libs-team#622
- Implementation: Add
core::mem::DropGuard
#144236 - Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
- What should the name of the type be?
DropGuard
,WithDrop
andDropper
were some of the preferred options raised in the 2025-07-22 T-Libs-API call. - Should the impl have a
Clone
impl? This can always be added in the future, but should be discussed further prior to stabilization. - Should the
Debug
impl be transparent? This can always be added in the future, but should be discussed further prior to stabilization.
Footnotes
Metadata
Metadata
Assignees
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-unimplementedStatus: The feature has not been implemented.Status: The feature has not been implemented.T-libs-apiRelevant to the library API 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.