@@ -79,30 +79,30 @@ where
7979 ///
8080 /// let value = String::from("Nori likes chicken");
8181 /// let guard = DropGuard::new(value, |s| println!("{s}"));
82- /// assert_eq!(guard. dismiss(), "Nori likes chicken");
82+ /// assert_eq!(DropGuard:: dismiss(guard ), "Nori likes chicken");
8383 /// ```
8484 #[ unstable( feature = "drop_guard" , issue = "144426" ) ]
8585 #[ rustc_const_unstable( feature = "const_drop_guard" , issue = "none" ) ]
8686 #[ inline]
87- pub const fn dismiss ( self ) -> T
87+ pub const fn dismiss ( guard : Self ) -> T
8888 where
8989 F : [ const ] Destruct ,
9090 {
9191 // First we ensure that dropping the guard will not trigger
9292 // its destructor
93- let mut this = ManuallyDrop :: new ( self ) ;
93+ let mut guard = ManuallyDrop :: new ( guard ) ;
9494
9595 // Next we manually read the stored value from the guard.
9696 //
9797 // SAFETY: this is safe because we've taken ownership of the guard.
98- let value = unsafe { ManuallyDrop :: take ( & mut this . inner ) } ;
98+ let value = unsafe { ManuallyDrop :: take ( & mut guard . inner ) } ;
9999
100100 // Finally we drop the stored closure. We do this *after* having read
101101 // the value, so that even if the closure's `drop` function panics,
102102 // unwinding still tries to drop the value.
103103 //
104104 // SAFETY: this is safe because we've taken ownership of the guard.
105- unsafe { ManuallyDrop :: drop ( & mut this . f ) } ;
105+ unsafe { ManuallyDrop :: drop ( & mut guard . f ) } ;
106106 value
107107 }
108108}
0 commit comments