pub trait BoolPacker {
// Required methods
fn pack_bool(first: bool, second: bool) -> Self;
fn first_bool(&self) -> bool;
fn second_bool(&self) -> bool;
// Provided method
fn unpack_bool(&self) -> (bool, bool) { ... }
}Expand description
Trait for packing and unpacking two bool values into a single value.
Required Methods§
Sourcefn pack_bool(first: bool, second: bool) -> Self
fn pack_bool(first: bool, second: bool) -> Self
Packs two bool values into a single value of the implementing type.
§Example
use num_packer::BoolPacker;
let packed = u8::pack_bool(true, false);
assert_eq!(packed, 0b10);Sourcefn first_bool(&self) -> bool
fn first_bool(&self) -> bool
Gets the first bool value from the packed representation.
§Example
use num_packer::BoolPacker;
let packed = u8::pack_bool(true, false);
assert_eq!(packed.first_bool(), true);Sourcefn second_bool(&self) -> bool
fn second_bool(&self) -> bool
Gets the second bool value from the packed representation.
§Example
use num_packer::BoolPacker;
let packed = u8::pack_bool(true, false);
assert_eq!(packed.second_bool(), false);Provided Methods§
Sourcefn unpack_bool(&self) -> (bool, bool)
fn unpack_bool(&self) -> (bool, bool)
Unpacks the single value back into two bool values.
§Example
use num_packer::BoolPacker;
let packed = u8::pack_bool(true, false);
let (first, second) = packed.unpack_bool();
assert_eq!((first, second), (true, false));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.