Trait moore_vhdl::konst2::Const2
source · [−]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
fn into_owned(self) -> OwnedConst<'t>
fn into_owned(self) -> OwnedConst<'t>
Convert into an owned constant.
fn to_owned(&self) -> OwnedConst<'t>
fn to_owned(&self) -> OwnedConst<'t>
Clone this constant.
Trait Implementations
sourceimpl<'t> AllocOwned<'t, 't, dyn Const2<'t> + 't> for ConstArena<'t>
impl<'t> AllocOwned<'t, 't, dyn Const2<'t> + 't> for ConstArena<'t>
sourcefn alloc_owned(&'t self, value: OwnedConst<'t>) -> &'t dyn Const2<'t>
fn alloc_owned(&'t self, value: OwnedConst<'t>) -> &'t dyn Const2<'t>
Allocate a value of type T: ToOwned
into this arena. Read more
sourcefn maybe_alloc(&'a self, value: Cow<'t, T>) -> &'t T
fn maybe_alloc(&'a self, value: Cow<'t, T>) -> &'t T
Conditionally allocate a value of type Cow<T>
. Read more
sourcefn force_alloc(&'a self, value: Cow<'_, T>) -> &'t T
fn force_alloc(&'a self, value: Cow<'_, T>) -> &'t T
Forcefully allocate a value of type Cow<T>
. Read more
sourceimpl<'t> Borrow<dyn Const2<'t> + 't> for OwnedConst<'t>
impl<'t> Borrow<dyn Const2<'t> + 't> for OwnedConst<'t>
sourceimpl<'t> ToOwned for dyn Const2<'t> + 't
impl<'t> ToOwned for dyn Const2<'t> + 't
type Owned = OwnedConst<'t>
type Owned = OwnedConst<'t>
The resulting type after obtaining ownership.
sourcefn to_owned(&self) -> OwnedConst<'t>
fn to_owned(&self) -> OwnedConst<'t>
Creates owned data from borrowed data, usually by cloning. Read more
sourcefn clone_into(&self, target: &mut Self::Owned)
fn clone_into(&self, target: &mut Self::Owned)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more