pub union ManuallyDrop<T> {
// some fields omitted
}
A wrapper to inhibit compiler from automatically calling T
’s destructor.
This wrapper is 0-cost.
This wrapper helps with explicitly documenting the drop order dependencies between fields of
the type:
use std::mem::ManuallyDrop;
struct Peach;
struct Banana;
struct Melon;
struct FruitBox {
peach: ManuallyDrop<Peach>,
melon: Melon,
banana: ManuallyDrop<Banana>,
}
impl Drop for FruitBox {
fn drop(&mut self) {
unsafe {
ManuallyDrop::drop(&mut self.peach);
ManuallyDrop::drop(&mut self.banana);
}
}
}Run
Wrap a value to be manually dropped.
use std::mem::ManuallyDrop;
ManuallyDrop::new(Box::new(()));Run
Extract the value from the ManuallyDrop container.
use std::mem::ManuallyDrop;
let x = ManuallyDrop::new(Box::new(()));
let _: Box<()> = ManuallyDrop::into_inner(x);Run
Manually drops the contained value.
This function runs the destructor of the contained value and thus the wrapped value
now represents uninitialized data. It is up to the user of this method to ensure the
uninitialized data is not actually used.
Mutably dereferences the value.
The resulting type after dereferencing.
Formats the value using the given formatter. Read more
Returns the "default value" for a type. Read more
Performs copy-assignment from source
. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self | 1.21.0 [src] |
[−]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self | 1.21.0 [src] |
[−]
Compares and returns the minimum of two values. Read more
This method tests for self
and other
values to be equal, and is used by ==
. Read more
This method tests for !=
.
Feeds this value into the given [Hasher
]. Read more
Feeds a slice of this type into the given [Hasher
]. Read more