Expand description
Transmutation of trivial objects
Functions in this module are guarded from out-of-bounds memory access and
from unsafe transmutation target types through the use of the
TriviallyTransmutable
) trait.
If a certain type can be safely constructed out of any byte combination,
then it may implement this trait. This is the case for primitive integer
types (e.g. i32
, u32
, i64
), arrays of other trivially transmutable
types, and repr(C)
structs composed of trivially transmutable values.
However, they are still not entirely safe because the source data may not be correctly aligned for reading and writing a value of the target type. The effects of this range from less performance (e.g. x86) to trapping or address flooring (e.g. ARM), but this is undefined behavior nonetheless.
Traits§
- Trivially
Transmutable - Type that can be constructed from any combination of bytes.
Functions§
- align_
to - Transmute the slice to a slice of another type, ensuring alignment of the types is maintained.
- align_
to_ mut - Transmute the slice to a slice of another type, ensuring alignment of the types is maintained.
- guarded_
transmute_ ⚠pod_ many_ pedantic Deprecated - View a byte slice as a slice of a trivially transmutable type.
- guarded_
transmute_ ⚠pod_ many_ permissive Deprecated - View a byte slice as a slice of a trivially transmutable type.
- transmute_
trivial ⚠ - Transmute a byte slice into a single instance of a trivially transmutable type.
- transmute_
trivial_ ⚠many - Transmute a byte slice into a single instance of a trivially transmutable type.
- transmute_
trivial_ ⚠many_ mut - Transmute a byte slice into a single instance of a trivially transmutable type.
- transmute_
trivial_ ⚠pedantic - Transmute a byte slice into a single instance of a trivially transmutable type.
- transmute_
trivial_ ⚠vec - Transform a vector into a vector of another element type.