pub trait Mem {
const NEEDS_DROP: bool = _;
// Provided methods
fn mem_needs_drop(&self) -> bool { ... }
fn mem_drop(self)
where Self: Sized { ... }
fn mem_forget(self)
where Self: Sized { ... }
fn mem_replace(&mut self, other: Self) -> Self
where Self: Sized { ... }
fn mem_take(&mut self) -> Self
where Self: Default { ... }
fn mem_swap(&mut self, other: &mut Self)
where Self: Sized { ... }
fn mem_as_bytes(&self) -> &[u8] ⓘ
where Self: Sync + Unpin { ... }
fn mem_as_bytes_mut(&mut self) -> &mut [u8] ⓘ
where Self: Sync + Unpin { ... }
}
Expand description
A trait for type memory information and manipulation.
This trait is automatically implemented for every ?Sized
type,
although most methods are only available where Self: Sized
.
Provided Associated Constants§
sourceconst NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Whether dropping values of this type matters.
Provided Methods§
sourcefn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
Returns true
if dropping values of this type matters.
sourcefn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
Forgets about self
without running its destructor.
sourcefn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Replaces self
with other, returning the previous value of self
.
sourcefn mem_take(&mut self) -> Selfwhere
Self: Default,
fn mem_take(&mut self) -> Selfwhere
Self: Default,
Replaces self
with its default value, returning the previous value of self
.
sourcefn mem_swap(&mut self, other: &mut Self)where
Self: Sized,
fn mem_swap(&mut self, other: &mut Self)where
Self: Sized,
Swaps the value of self
and other
without deinitializing either one.
sourcefn mem_as_bytes(&self) -> &[u8] ⓘ
Available on crate feature unsafe_slice
only.
fn mem_as_bytes(&self) -> &[u8] ⓘ
unsafe_slice
only.View a Sync + Unpin
self
as &[u8]
.
For the const
version for sized types see [mem_as_bytes_sized
].
Object Safety§
This trait is not object safe.