Skip to content

Commit 30cdb68

Browse files
committed
DropGuard::into_inner -> DropGuard::dismiss
Also changes it from a static method to an instance method.
1 parent c5e283b commit 30cdb68

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

library/core/src/mem/drop_guard.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,10 @@ where
6363

6464
/// Consumes the `DropGuard`, returning the wrapped value.
6565
///
66-
/// This will not execute the closure. This is implemented as an associated
67-
/// function to prevent any potential conflicts with any other methods called
68-
/// `into_inner` from the `Deref` and `DerefMut` impls.
69-
///
70-
/// It is typically preferred to call this function instead of `mem::forget`
71-
/// because it will return the stored value and drop variables captured
72-
/// by the closure instead of leaking their owned resources.
66+
/// This will not execute the closure. It is typically preferred to call
67+
/// this function instead of `mem::forget` because it will return the stored
68+
/// value and drop variables captured by the closure instead of leaking their
69+
/// owned resources.
7370
///
7471
/// # Example
7572
///
@@ -81,11 +78,11 @@ where
8178
///
8279
/// let value = String::from("Nori likes chicken");
8380
/// let guard = DropGuard::new(value, |s| println!("{s}"));
84-
/// assert_eq!(DropGuard::into_inner(guard), "Nori likes chicken");
81+
/// assert_eq!(guard.dismiss(), "Nori likes chicken");
8582
/// ```
8683
#[unstable(feature = "drop_guard", issue = "144426")]
8784
#[inline]
88-
pub fn into_inner(guard: Self) -> T {
85+
pub fn dismiss(self) -> T {
8986
// First we ensure that dropping the guard will not trigger
9087
// its destructor
9188
let mut guard = ManuallyDrop::new(guard);

0 commit comments

Comments
 (0)