Type Definition moore_vhdl::ty2::IntegerSubtype
source · [−]pub type IntegerSubtype<'t> = ScalarSubtype<'t, dyn IntegerType, BigInt>;
Expand description
A subtype of an integer type.
Implementations
sourceimpl<'t> IntegerSubtype<'t>
impl<'t> IntegerSubtype<'t>
sourcepub fn new(
mark: &'t TypeMark<'t>,
range: Range<BigInt>
) -> Option<IntegerSubtype<'t>>
pub fn new(
mark: &'t TypeMark<'t>,
range: Range<BigInt>
) -> Option<IntegerSubtype<'t>>
Create a new integer subtype.
Returns Some(...)
if range
is a subrange of the integer, or None
otherwise.
Example
use moore_vhdl::ty2::{Type, TypeMark, IntegerBasetype, IntegerSubtype, Range};
use moore_common::name::get_name_table;
let ty = IntegerBasetype::new(Range::ascending(0usize, 255usize));
let tm = TypeMark::new(
get_name_table().intern("BYTE", false),
&ty,
);
let a = IntegerSubtype::new(&tm, Range::ascending(0usize, 15usize)).unwrap();
let b = IntegerSubtype::new(&tm, Range::descending(15usize, 0usize)).unwrap();
assert_eq!(format!("{}", a), "BYTE range 0 to 15");
assert_eq!(format!("{}", b), "BYTE range 15 downto 0");
Trait Implementations
sourceimpl<'t> Display for IntegerSubtype<'t>
impl<'t> Display for IntegerSubtype<'t>
sourceimpl<'t> IntegerType for IntegerSubtype<'t>
impl<'t> IntegerType for IntegerSubtype<'t>
sourcefn range(&self) -> Option<&Range<BigInt>>
fn range(&self) -> Option<&Range<BigInt>>
The range of values this integer can assume. Read more
sourcefn as_subtype(&self) -> Option<&IntegerSubtype<'_>>
fn as_subtype(&self) -> Option<&IntegerSubtype<'_>>
Returns Some
if self is an IntegerSubtype
, None
otherwise.
sourcefn is_equal(&self, other: &dyn IntegerType) -> bool
fn is_equal(&self, other: &dyn IntegerType) -> bool
Check if two integer types are equal.
sourcefn resolution_func(&self) -> Option<usize>
fn resolution_func(&self) -> Option<usize>
The resolution function associated with this type.
sourcefn as_basetype(&self) -> Option<&IntegerBasetype>
fn as_basetype(&self) -> Option<&IntegerBasetype>
Returns Some
if self is an IntegerBasetype
, None
otherwise.
sourcefn is_universal(&self) -> bool
fn is_universal(&self) -> bool
Checks whether this is a universal integer type.
sourcefn unwrap_basetype(&self) -> &IntegerBasetype
fn unwrap_basetype(&self) -> &IntegerBasetype
Returns an &IntegerBasetype
or panics if the type is not a basetype.
sourcefn unwrap_subtype(&self) -> &IntegerSubtype<'_>
fn unwrap_subtype(&self) -> &IntegerSubtype<'_>
Returns an &IntegerSubtype
or panics if the type is not a subtype.
sourceimpl<'t> Type for IntegerSubtype<'t>
impl<'t> Type for IntegerSubtype<'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.