Trait mz_ore::cast::ReinterpretCast
source · pub trait ReinterpretCast<T> {
// Required method
fn reinterpret_cast(from: T) -> Self;
}
Expand description
A trait for reinterpreting casts.
ReinterpretCast
is like as
, but it allows the caller to be specific about their
intentions to reinterpreting the bytes from one type to another. For example, if we
have some u32
that we want to use as the return value of a postgres function, and
we don’t mind converting large unsigned numbers to negative signed numbers, then
we would use ReinterpretCast<i32>
.
ReinterpretCast
should be preferred to the as
operator, since it explicitly
conveys the intention to reinterpret the type.
Required Methods§
sourcefn reinterpret_cast(from: T) -> Self
fn reinterpret_cast(from: T) -> Self
Performs the cast.
Object Safety§
This trait is not object safe.