I16Packer

Trait I16Packer 

Source
pub trait I16Packer {
    // Required methods
    fn pack_i16(first: i16, second: i16) -> Self;
    fn unpack_i16(&self) -> (i16, i16);
}
Expand description

Trait for packing and unpacking two i16 values into a single value.

Required Methods§

Source

fn pack_i16(first: i16, second: i16) -> Self

Packs two i16 values into a single value of the implementing type.

§Example
use num_packer::I16Packer;
let packed = u32::pack_i16(-20000, 15000);
assert_eq!(packed, ((-20000i16 as u16 as u32) << 16) + (15000u16 as u32));
Source

fn unpack_i16(&self) -> (i16, i16)

Unpacks the single value back into two i16 values.

§Example
use num_packer::I16Packer;
let packed = u32::pack_i16(-20000, 15000);
let (first, second) = packed.unpack_i16();
assert_eq!((first, second), (-20000, 15000));

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.

Implementations on Foreign Types§

Source§

impl I16Packer for i32

Source§

fn pack_i16(first: i16, second: i16) -> Self

Source§

fn unpack_i16(&self) -> (i16, i16)

Source§

impl I16Packer for i64

Source§

fn pack_i16(first: i16, second: i16) -> Self

Source§

fn unpack_i16(&self) -> (i16, i16)

Source§

impl I16Packer for isize

Source§

fn pack_i16(first: i16, second: i16) -> Self

Source§

fn unpack_i16(&self) -> (i16, i16)

Source§

impl I16Packer for u32

Source§

fn pack_i16(first: i16, second: i16) -> Self

Source§

fn unpack_i16(&self) -> (i16, i16)

Source§

impl I16Packer for u64

Source§

fn pack_i16(first: i16, second: i16) -> Self

Source§

fn unpack_i16(&self) -> (i16, i16)

Source§

impl I16Packer for usize

Source§

fn pack_i16(first: i16, second: i16) -> Self

Source§

fn unpack_i16(&self) -> (i16, i16)

Implementors§