Skip to main content

Width

Trait Width 

Source
pub trait Width:
    Copy
    + Eq
    + Debug {
    // Required methods
    fn fixed(size: usize) -> Self;
    fn size(self) -> Option<usize>;

    // Provided method
    fn operand(_table: TableId) -> Option<Self> { ... }
}
Expand description

A width in the domain a width-inference pass works over.

Per-instruction planning knows every width as a concrete byte count. A producer resolving its own source bodies does not: a body’s local can take its width from a table operand whose export only exists once an instruction is decoded. Naming that dependency rather than dropping it is what makes the two passes agree — a pass that simply skipped the unknown would size the local from a later statement and reach a different answer.

Required Methods§

Source

fn fixed(size: usize) -> Self

A concrete width in bytes.

Source

fn size(self) -> Option<usize>

This width as a byte count, if it is concrete. Arithmetic on a width uses this, so a symbolic width yields no constraint rather than a wrong one.

Provided Methods§

Source

fn operand(_table: TableId) -> Option<Self>

The width of the value a sub-table operand exports, if this domain can name it. Concrete domains cannot, and report the width as unknown.

Only a table operand is nameable. A decoder field substitutes an integer literal, and a literal deliberately establishes no width, so naming one would claim a width the per-instruction pass never infers.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Width for usize

Source§

fn fixed(size: usize) -> Self

Source§

fn size(self) -> Option<usize>

Implementors§