Struct bitfield_layout::layouts::DualView[][src]

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 str1: &'a str

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.