pub struct DualView<'a>(pub &'a str, pub &'a str);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 strTrait Implementations§
Source§impl<'a> Ord for DualView<'a>
impl<'a> Ord for DualView<'a>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<'a> PartialOrd for DualView<'a>
impl<'a> PartialOrd for DualView<'a>
impl<'a> Eq for DualView<'a>
impl<'a> StructuralPartialEq for DualView<'a>
Auto Trait Implementations§
impl<'a> Freeze for DualView<'a>
impl<'a> RefUnwindSafe for DualView<'a>
impl<'a> Send for DualView<'a>
impl<'a> Sync for DualView<'a>
impl<'a> Unpin for DualView<'a>
impl<'a> UnwindSafe for DualView<'a>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more