#[repr(u8)]pub enum Width {
B1,
B2,
B4,
}
Expand description
Byte width of the bus read/write.
Variants§
Implementations§
source§impl Width
impl Width
sourcepub const fn from_num_bytes(num_bytes: usize) -> Self
pub const fn from_num_bytes(num_bytes: usize) -> Self
assert_eq!(Width::from_num_bytes(1), Width::B1);
assert_eq!(Width::from_num_bytes(2), Width::B2);
assert_eq!(Width::from_num_bytes(4), Width::B4);
sourcepub const fn from_reg<T>(_: &T) -> Self
pub const fn from_reg<T>(_: &T) -> Self
Returns the width of the given RAL register instance, i.e. &RWRegister<u32>
and friends.
Since RWRegister<T>
is a newtype wrapper of T
, this works on primitives too.
let a = 1u8;
let b = 2u16;
let c = 3i32;
assert_eq!(Width::from_reg(&a), Width::B1);
assert_eq!(Width::from_reg(&b), Width::B2);
assert_eq!(Width::from_reg(&c), Width::B4);
Trait Implementations§
source§impl PartialEq<Width> for Width
impl PartialEq<Width> for Width
impl Copy for Width
impl Eq for Width
impl StructuralEq for Width
impl StructuralPartialEq for Width
Auto Trait Implementations§
impl RefUnwindSafe for Width
impl Send for Width
impl Sync for Width
impl Unpin for Width
impl UnwindSafe for Width
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