pub trait ExtMem {
const NEEDS_DROP: bool = _;
Show 15 methods
// Provided methods
fn mem_align_of<T>() -> usize ⓘ { ... }
fn mem_align_of_val(&self) -> usize ⓘ { ... }
fn mem_size_of<T>() -> usize ⓘ { ... }
fn mem_size_of_val(&self) -> usize ⓘ { ... }
fn mem_copy(&self) -> Self
where Self: Copy { ... }
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 { ... }
unsafe fn mem_zeroed<T>() -> T { ... }
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst { ... }
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
Extension 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 = _
Know whether dropping values of this type matters, in compile-time.
Provided Methods§
Sourcefn mem_align_of<T>() -> usize ⓘ
fn mem_align_of<T>() -> usize ⓘ
Returns the minimum alignment of the type in bytes.
See Mem::align_of
.
Sourcefn mem_align_of_val(&self) -> usize ⓘ
fn mem_align_of_val(&self) -> usize ⓘ
Returns the alignment of the pointed-to value in bytes.
See Mem::align_of_val
.
Sourcefn mem_size_of<T>() -> usize ⓘ
fn mem_size_of<T>() -> usize ⓘ
Returns the size of a type in bytes.
See Mem::size_of
.
Sourcefn mem_size_of_val(&self) -> usize ⓘ
fn mem_size_of_val(&self) -> usize ⓘ
Returns the size of the pointed-to value in bytes.
See Mem::size_of_val
.
Sourcefn mem_copy(&self) -> Selfwhere
Self: Copy,
fn mem_copy(&self) -> Selfwhere
Self: Copy,
Bitwise-copies a value.
It is useful when you want to pass a function pointer to a combinator, rather than defining a new closure.
See Mem::copy
.
Sourcefn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
Returns true
if dropping values of this type matters.
See Mem::needs_drop
.
Sourcefn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
Forgets about self
without running its destructor.
See Mem::forget
.
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
.
See Mem::replace
.
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
.
See Mem::take
.
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.
See Mem::swap
.
Sourceunsafe fn mem_zeroed<T>() -> T
Available on crate feature unsafe_layout
only.
unsafe fn mem_zeroed<T>() -> T
unsafe_layout
only.Sourceunsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
Available on crate feature unsafe_layout
only.
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe_layout
only.Returns the value of type T
represented by the all-zero byte-pattern.
§Safety
See Mem::transmute_copy
.
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]
.
See Mem::as_bytes
, and for the const
version for sized types
see Mem::as_bytes_sized
.
Sourcefn mem_as_bytes_mut(&mut self) -> &mut [u8] ⓘ
Available on crate feature unsafe_slice
only.
fn mem_as_bytes_mut(&mut self) -> &mut [u8] ⓘ
unsafe_slice
only.View a Sync + Unpin
self
as &mut [u8]
.
See Mem::as_bytes_mut
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.