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§
Sourcefn pack_f32(first: f32, second: f32) -> Self
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);Sourcefn first_f32(&self) -> f32
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);Sourcefn second_f32(&self) -> f32
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§
Sourcefn unpack_f32(&self) -> (f32, f32)
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.