Enum rustc_mir::interpret::Scalar[][src]

pub enum Scalar<Tag = AllocId> {
    Int(ScalarInt),
    Ptr(Pointer<Tag>, u8),
}
Expand description

A Scalar represents an immediate, primitive value existing outside of a memory::Allocation. It is in many ways like a small chunk of a Allocation, up to 16 bytes in size. Like a range of bytes in an Allocation, a Scalar can either represent the raw bytes of a simple value or a pointer into another Allocation

These variants would be private if there was a convenient way to achieve that in Rust. Do not match on a Scalar! Use the various to_* methods instead.

Variants

Int(ScalarInt)

The raw bytes of a simple value.

Ptr(Pointer<Tag>, u8)

A pointer into an Allocation. An Allocation in the memory module has a list of relocations, but a Scalar is only large enough to contain one, so we just represent the relocation and its associated offset together as a Pointer here.

We also store the size of the pointer, such that a Scalar always knows how big it is. The size is always the pointer size of the current target, but this is not information that we always have readily available.

Trait Implementations

Performs the conversion.

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.

Layout

Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.