Struct bitfield_layout::layouts::DualView [−][src]
Expand description
Simple structure for basic and alternate string view
This struct may be used in most cases of crate using. We can rewrite 6502 status register example using this struct
struct StatusRegister(u8); impl StatusRegister { const LAYOUT: [DualView<'static>; 8] = [ DualView( "Carry flag", "Enables numbers larger than a single word to be added/subtracted by carrying a binary digit from a less significant word to the least significant bit of a more significant word as needed." ), DualView( "Zero flag", "Indicates that the result of an arithmetic or logical operation (or, sometimes, a load) was zero." ), DualView( "Interrupt flag", "Indicates whether interrupts are enabled or masked." ), DualView( "Decimal flag", "Indicates that a bit carry was produced between the nibbles as a result of the last arithmetic operation." ), DualView( "Break flag", "It can be examined as a value stored on the stack." ), DualView("Unused", "Unused"), DualView( "Overflow flag", "Indicates that the signed result of an operation is too large to fit in the register width using two's complement representation." ), DualView( "Negative flag", "Indicates that the result of a mathematical operation is negative." ), ]; } impl Layout for StatusRegister { type Layout = slice::Iter<'static, DualView<'static>>; fn layout() -> Self::Layout { StatusRegister::LAYOUT.iter() } } impl BitFieldLayout for StatusRegister { type Value = u8; fn get(&self) -> Self::Value { self.0 } fn set(&mut self, new: Self::Value) { self.0 = new; } }
Tuple Fields
0: &'a str
1: &'a str
Trait Implementations
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl<'a> RefUnwindSafe for DualView<'a>
impl<'a> UnwindSafe for DualView<'a>
Blanket Implementations
Mutably borrows from an owned value. Read more