Skip to main content

ConstantValue

Trait ConstantValue 

Source
pub trait ConstantValue: Sized {
    // Provided methods
    fn string(index: u32) -> Option<Self> { ... }
    fn function(index: u32) -> Option<Self> { ... }
    fn string_index(&self) -> Option<u32> { ... }
    fn function_index(&self) -> Option<u32> { ... }
}
Expand description

A value that can live in the constant pool of a standard header.

.const str "text" and .const fn @name are assembled through string and function; a value model without string or function constants returns None and such directives are rejected. string_index and function_index report the table references of a value, so that a hand-written index such as .const str 3 is rejected and tools can explain constants.

Provided Methods§

Source

fn string(index: u32) -> Option<Self>

The constant for strings[index].

Source

fn function(index: u32) -> Option<Self>

The constant for functions[index].

Source

fn string_index(&self) -> Option<u32>

The strings index this constant refers to, if any.

Source

fn function_index(&self) -> Option<u32>

The functions index this constant refers to, if any.

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 ConstantValue for Value

Source§

fn string(index: u32) -> Option<Self>

Source§

fn function(index: u32) -> Option<Self>

Source§

fn string_index(&self) -> Option<u32>

Source§

fn function_index(&self) -> Option<u32>

Implementors§