pub struct ReplaceDrop<T: ReplaceDropImpl>(/* private fields */);
Expand description
A wrapper around ManuallyDrop that instead of removing the drop, replaces it Example:
use replace_drop::{ReplaceDropImpl, ReplaceDrop};
struct MyData { data: i32 }
unsafe impl ReplaceDropImpl for MyData {
unsafe fn drop(&mut self) {
println!("Called drop with {}", self.data)
}
}
let data = MyData {data: 3};
let data2 = MyData {data: 3};
drop(data); // Prints nothing
let data_replace_drop = ReplaceDrop::new(data2);
drop(data_replace_drop); // Prints "Called drop with 3"
Implementations§
Source§impl<T: ReplaceDropImpl> ReplaceDrop<T>
impl<T: ReplaceDropImpl> ReplaceDrop<T>
pub fn new_from_manually_drop(val: ManuallyDrop<T>) -> Self
pub fn into_inner(self) -> T
Trait Implementations§
Source§impl<T: Clone + ReplaceDropImpl> Clone for ReplaceDrop<T>
impl<T: Clone + ReplaceDropImpl> Clone for ReplaceDrop<T>
Source§fn clone(&self) -> ReplaceDrop<T>
fn clone(&self) -> ReplaceDrop<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<T: Debug + ReplaceDropImpl> Debug for ReplaceDrop<T>
impl<T: Debug + ReplaceDropImpl> Debug for ReplaceDrop<T>
Source§impl<T: ReplaceDropImpl> Deref for ReplaceDrop<T>
impl<T: ReplaceDropImpl> Deref for ReplaceDrop<T>
Source§impl<T: ReplaceDropImpl> DerefMut for ReplaceDrop<T>
impl<T: ReplaceDropImpl> DerefMut for ReplaceDrop<T>
Source§impl<T: ReplaceDropImpl> Drop for ReplaceDrop<T>
impl<T: ReplaceDropImpl> Drop for ReplaceDrop<T>
Auto Trait Implementations§
impl<T> Freeze for ReplaceDrop<T>where
T: Freeze,
impl<T> RefUnwindSafe for ReplaceDrop<T>where
T: RefUnwindSafe,
impl<T> Send for ReplaceDrop<T>where
T: Send,
impl<T> Sync for ReplaceDrop<T>where
T: Sync,
impl<T> Unpin for ReplaceDrop<T>where
T: Unpin,
impl<T> UnwindSafe for ReplaceDrop<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more