Type Definition moore_vhdl::ty2::PhysicalSubtype
source · [−]pub type PhysicalSubtype<'t> = ScalarSubtype<'t, dyn PhysicalType, BigInt>;
Expand description
A subtype of an integer type.
Implementations
sourceimpl<'t> PhysicalSubtype<'t>
impl<'t> PhysicalSubtype<'t>
sourcepub fn new(
mark: &'t TypeMark<'t>,
range: Range<BigInt>
) -> Option<PhysicalSubtype<'t>>
pub fn new(
mark: &'t TypeMark<'t>,
range: Range<BigInt>
) -> Option<PhysicalSubtype<'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, PhysicalUnit, PhysicalBasetype, PhysicalSubtype, Range};
use moore_common::name::get_name_table;
let ty = PhysicalBasetype::new(Range::ascending(-1000isize, 1000isize), vec![
PhysicalUnit::primary(get_name_table().intern("fs", false), 1),
PhysicalUnit::secondary(get_name_table().intern("ps", false), 1000, 1000, 0),
], 0);
let tm = TypeMark::new(
get_name_table().intern("TIME", false),
&ty,
);
let a = PhysicalSubtype::new(&tm, Range::ascending(0isize, 100isize)).unwrap();
let b = PhysicalSubtype::new(&tm, Range::descending(100isize, 0isize)).unwrap();
assert_eq!(format!("{}", a), "TIME range 0 to 100");
assert_eq!(format!("{}", b), "TIME range 100 downto 0");
Trait Implementations
sourceimpl<'t> Display for PhysicalSubtype<'t>
impl<'t> Display for PhysicalSubtype<'t>
sourceimpl<'t> PhysicalType for PhysicalSubtype<'t>
impl<'t> PhysicalType for PhysicalSubtype<'t>
sourcefn units(&self) -> &[PhysicalUnit]
fn units(&self) -> &[PhysicalUnit]
The units of measure of this type.
sourcefn primary_index(&self) -> usize
fn primary_index(&self) -> usize
The index of the primary unit.
sourcefn as_subtype(&self) -> Option<&PhysicalSubtype<'_>>
fn as_subtype(&self) -> Option<&PhysicalSubtype<'_>>
Returns Some
if self is a PhysicalSubtype
, None
otherwise.
sourcefn is_equal(&self, other: &dyn PhysicalType) -> bool
fn is_equal(&self, other: &dyn PhysicalType) -> bool
Check if two physical 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<&PhysicalBasetype>
fn as_basetype(&self) -> Option<&PhysicalBasetype>
Returns Some
if self is a PhysicalBasetype
, None
otherwise.
sourcefn unwrap_basetype(&self) -> &PhysicalBasetype
fn unwrap_basetype(&self) -> &PhysicalBasetype
Returns an &PhysicalBasetype
or panics if the type is not a basetype.
sourcefn unwrap_subtype(&self) -> &PhysicalSubtype<'_>
fn unwrap_subtype(&self) -> &PhysicalSubtype<'_>
Returns an &PhysicalSubtype
or panics if the type is not a subtype.
sourceimpl<'t> Type for PhysicalSubtype<'t>
impl<'t> Type for PhysicalSubtype<'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.