Type Definition moore_vhdl::ty2::FloatingSubtype
source · [−]pub type FloatingSubtype<'t> = ScalarSubtype<'t, dyn FloatingType, f64>;
Expand description
A subtype of an real type.
Implementations
sourceimpl<'t> FloatingSubtype<'t>
impl<'t> FloatingSubtype<'t>
sourcepub fn new(
mark: &'t TypeMark<'t>,
range: Range<f64>
) -> Option<FloatingSubtype<'t>>
pub fn new(
mark: &'t TypeMark<'t>,
range: Range<f64>
) -> Option<FloatingSubtype<'t>>
Create a new real subtype.
Returns Some(...)
if range
is a subrange of the real, or None
otherwise.
Example
use moore_common::name::get_name_table;
use moore_vhdl::ty2::{Type, TypeMark, FloatingBasetype, FloatingSubtype, Range};
let ty = FloatingBasetype::new(Range::ascending(0.0, 1.0));
let tm = TypeMark::new(
get_name_table().intern("UNIT", false),
&ty,
);
let a = FloatingSubtype::new(&tm, Range::ascending(0.0, 0.5)).unwrap();
let b = FloatingSubtype::new(&tm, Range::descending(0.5, 0.0)).unwrap();
assert_eq!(format!("{}", a), "UNIT range 0 to 0.5");
assert_eq!(format!("{}", b), "UNIT range 0.5 downto 0");
Trait Implementations
sourceimpl<'t> Display for FloatingSubtype<'t>
impl<'t> Display for FloatingSubtype<'t>
sourceimpl<'t> FloatingType for FloatingSubtype<'t>
impl<'t> FloatingType for FloatingSubtype<'t>
sourcefn as_subtype(&self) -> Option<&FloatingSubtype<'_>>
fn as_subtype(&self) -> Option<&FloatingSubtype<'_>>
Returns Some
if self is an FloatingSubtype
, None
otherwise.
sourcefn is_equal(&self, other: &dyn FloatingType) -> bool
fn is_equal(&self, other: &dyn FloatingType) -> bool
Check if two real 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<&FloatingBasetype>
fn as_basetype(&self) -> Option<&FloatingBasetype>
Returns Some
if self is an FloatingBasetype
, None
otherwise.
sourcefn is_universal(&self) -> bool
fn is_universal(&self) -> bool
Checks whether this is a universal real type.
sourcefn unwrap_basetype(&self) -> &FloatingBasetype
fn unwrap_basetype(&self) -> &FloatingBasetype
Returns an &FloatingBasetype
or panics if the type is not a basetype.
sourcefn unwrap_subtype(&self) -> &FloatingSubtype<'_>
fn unwrap_subtype(&self) -> &FloatingSubtype<'_>
Returns an &FloatingSubtype
or panics if the type is not a subtype.
sourceimpl<'t> Type for FloatingSubtype<'t>
impl<'t> Type for FloatingSubtype<'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.