Type Definition moore_vhdl::ty2::EnumSubtype
source · [−]pub type EnumSubtype<'t> = ScalarSubtype<'t, dyn EnumType, usize>;
Expand description
A subtype of an enumeration type.
Implementations
sourceimpl<'t> EnumSubtype<'t>
impl<'t> EnumSubtype<'t>
sourcepub fn new(
mark: &'t TypeMark<'t>,
range: Range<usize>
) -> Option<EnumSubtype<'t>>
pub fn new(
mark: &'t TypeMark<'t>,
range: Range<usize>
) -> Option<EnumSubtype<'t>>
Create a new enumeration subtype.
Example
use moore_vhdl::ty2::{Type, TypeMark, EnumBasetype, EnumSubtype, Range};
use moore_common::name::get_name_table;
let ty = EnumBasetype::new(vec![
"first".into(),
"second".into(),
'0'.into(),
'1'.into(),
]);
let tm = TypeMark::new(
get_name_table().intern("MY_TYPE", false),
&ty,
);
let subty = EnumSubtype::new(&tm, Range::ascending(1usize, 2usize)).unwrap();
assert_eq!(format!("{}", subty), "MY_TYPE range second to '0'");
Trait Implementations
sourceimpl<'t> Display for EnumSubtype<'t>
impl<'t> Display for EnumSubtype<'t>
sourceimpl<'t> EnumType for EnumSubtype<'t>
impl<'t> EnumType for EnumSubtype<'t>
sourcefn variants(&self) -> &[EnumVariant]
fn variants(&self) -> &[EnumVariant]
The variants of this enumeration type.
sourcefn as_subtype(&self) -> Option<&EnumSubtype<'_>>
fn as_subtype(&self) -> Option<&EnumSubtype<'_>>
Returns Some
if self is an EnumSubtype
, None
otherwise.
sourcefn resolution_func(&self) -> Option<usize>
fn resolution_func(&self) -> Option<usize>
The resolution function associated with this type.
sourcefn as_basetype(&self) -> Option<&EnumBasetype>
fn as_basetype(&self) -> Option<&EnumBasetype>
Returns Some
if self is an EnumBasetype
, None
otherwise.
sourcefn unwrap_basetype(&self) -> &EnumBasetype
fn unwrap_basetype(&self) -> &EnumBasetype
Returns an &EnumBasetype
or panics if the type is not a basetype.
sourcefn unwrap_subtype(&self) -> &EnumSubtype<'_>
fn unwrap_subtype(&self) -> &EnumSubtype<'_>
Returns an &EnumSubtype
or panics if the type is not a subtype.
sourceimpl<'t> Type for EnumSubtype<'t>
impl<'t> Type for EnumSubtype<'t>
sourcefn is_discrete(&self) -> bool
fn is_discrete(&self) -> bool
Check if this is a discrete type. Read more
sourcefn is_numeric(&self) -> bool
fn is_numeric(&self) -> bool
Check if this is a numeric type. Read more
sourcefn is_composite(&self) -> bool
fn is_composite(&self) -> bool
Check if this is a composite type. Read more
sourcefn into_owned<'a>(self) -> OwnedType<'a> where
Self: 'a,
fn into_owned<'a>(self) -> OwnedType<'a> where
Self: 'a,
Convert into an owned type.
sourcefn is_implicitly_castable(&self, _into: &dyn Type) -> bool
fn is_implicitly_castable(&self, _into: &dyn Type) -> bool
Check if the type can be implicitly cast to another.