F32Packer

Trait F32Packer 

Source
pub trait F32Packer {
    // Required methods
    fn pack_f32(first: f32, second: f32) -> Self;
    fn first_f32(&self) -> f32;
    fn second_f32(&self) -> f32;

    // Provided method
    fn unpack_f32(&self) -> (f32, f32) { ... }
}
Expand description

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

Required Methods§

Source

fn pack_f32(first: f32, second: f32) -> Self

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

§Example
use num_packer::F32Packer;
let packed = u64::pack_f32(1.5, -2.5);
Source

fn first_f32(&self) -> f32

Gets the first f32 value from the packed representation.

§Example
use num_packer::F32Packer;
let packed = u64::pack_f32(1.5, -2.5);
assert_eq!(packed.first_f32(), 1.5);
Source

fn second_f32(&self) -> f32

Gets the second f32 value from the packed representation.

§Example
use num_packer::F32Packer;
let packed = u64::pack_f32(1.5, -2.5);
assert_eq!(packed.second_f32(), -2.5);

Provided Methods§

Source

fn unpack_f32(&self) -> (f32, f32)

Unpacks the single value back into two f32 values.

§Example
use num_packer::F32Packer;
let packed = u64::pack_f32(1.5, -2.5);
let (first, second) = packed.unpack_f32();
assert_eq!((first, second), (1.5, -2.5));

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 F32Packer for i64

Source§

fn pack_f32(first: f32, second: f32) -> Self

Source§

fn first_f32(&self) -> f32

Source§

fn second_f32(&self) -> f32

Source§

impl F32Packer for isize

Source§

fn pack_f32(first: f32, second: f32) -> Self

Source§

fn first_f32(&self) -> f32

Source§

fn second_f32(&self) -> f32

Source§

impl F32Packer for u64

Source§

fn pack_f32(first: f32, second: f32) -> Self

Source§

fn first_f32(&self) -> f32

Source§

fn second_f32(&self) -> f32

Source§

impl F32Packer for usize

Source§

fn pack_f32(first: f32, second: f32) -> Self

Source§

fn first_f32(&self) -> f32

Source§

fn second_f32(&self) -> f32

Implementors§