Macro zerocopy::transmute

source ·
macro_rules! transmute {
    ($e:expr) => { ... };
}
Expand description

Safely transmutes a value of one type to a value of another type of the same size.

The expression $e must have a concrete type, T, which implements AsBytes. The transmute! expression must also have a concrete type, U (U is inferred from the calling context), and U must implement FromBytes.

Note that the T produced by the expression $e will not be dropped. Semantically, its bits will be copied into a new value of type U, the original T will be forgotten, and the value of type U will be returned.