pub struct Div8(/* private fields */);Expand description
This type represents a divider in the range 1..=256.
At a hardware level, this is an 8-bit register from 0..=255, which adds one.
Implementations§
Source§impl Div8
impl Div8
Sourcepub const fn from_raw(n: u8) -> Self
pub const fn from_raw(n: u8) -> Self
Store a “raw” divisor value that will divide the source by
(n + 1), e.g. Div8::from_raw(0) will divide the source
by 1, and Div8::from_raw(255) will divide the source by
256.
Sourcepub const fn from_divisor(n: u16) -> Option<Self>
pub const fn from_divisor(n: u16) -> Option<Self>
Store a specific divisor value that will divide the source
by n. e.g. Div8::from_divisor(1) will divide the source
by 1, and Div8::from_divisor(256) will divide the source
by 256.
Will return None if n is not in the range 1..=256.
Consider Self::from_raw for an infallible version.
Sourcepub const fn into_divisor(self) -> u32
pub const fn into_divisor(self) -> u32
Convert into “divisor” form, as a u32 for convenient frequency math
Trait Implementations§
impl Copy for Div8
impl Eq for Div8
impl StructuralPartialEq for Div8
Auto Trait Implementations§
impl Freeze for Div8
impl RefUnwindSafe for Div8
impl Send for Div8
impl Sync for Div8
impl Unpin for Div8
impl UnwindSafe for Div8
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more