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§

source

fn reinterpret_cast(from: T) -> Self

Performs the cast.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl ReinterpretCast<i8> for u8

source§

impl ReinterpretCast<i16> for u16

source§

impl ReinterpretCast<i32> for u32

source§

impl ReinterpretCast<i64> for u64

source§

impl ReinterpretCast<u8> for i8

source§

impl ReinterpretCast<u16> for i16

source§

impl ReinterpretCast<u32> for i32

source§

impl ReinterpretCast<u64> for i64

Implementors§