pub trait Const2<'t>: Debug + Display {
    fn ty(&self) -> &'t dyn Type;
fn into_owned(self) -> OwnedConst<'t>;
fn to_owned(&self) -> OwnedConst<'t>;
fn as_any<'r>(&'r self) -> AnyConst<'r, 't>;
fn cast(
        &self,
        ty: &'t dyn Type
    ) -> Result<Cow<'_, dyn Const2<'t> + 't>, ConstError>; }
Expand description

An interface for dealing with constants.

This is the main trait which all constant values implement. Its purpose is to provide a convenient interface for inspecting and manipulating values. Dedicated structs for the specific types (e.g. integers, arrays, etc.) are expected to be allocated/internalized into an arena for ease of use.

Required methods

Return the type of the constant.

Convert into an owned constant.

Clone this constant.

Converts from &Const2 to AnyConst.

Cast the constant to a different type.

Trait Implementations

Allocate a value of type T: ToOwned into this arena. Read more

Conditionally allocate a value of type Cow<T>. Read more

Forcefully allocate a value of type Cow<T>. Read more

Immutably borrows from an owned value. Read more

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)

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

Implementors