Struct moore_vhdl::ty2::ScalarSubtype
source · [−]Expand description
A subtype of a scalar type.
Scalar types may be subtyped by a range constraint.
Implementations
sourceimpl<'t> ScalarSubtype<'t, dyn EnumType + 't, usize>
impl<'t> ScalarSubtype<'t, dyn EnumType + 't, usize>
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'");
sourceimpl<'t> ScalarSubtype<'t, dyn FloatingType + 't, f64>
impl<'t> ScalarSubtype<'t, dyn FloatingType + 't, f64>
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");
sourceimpl<'t> ScalarSubtype<'t, dyn IntegerType + 't, BigInt>
impl<'t> ScalarSubtype<'t, dyn IntegerType + 't, BigInt>
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");
sourceimpl<'t> ScalarSubtype<'t, dyn PhysicalType + 't, BigInt>
impl<'t> ScalarSubtype<'t, dyn PhysicalType + 't, BigInt>
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<'a, 't> Alloc<'a, 'a, ScalarSubtype<'t, dyn EnumType + 't, usize>> for TypeArena<'t> where
't: 'a,
impl<'a, 't> Alloc<'a, 'a, ScalarSubtype<'t, dyn EnumType + 't, usize>> for TypeArena<'t> where
't: 'a,
sourcefn alloc(&'a self, value: EnumSubtype<'t>) -> &'a mut EnumSubtype<'t>
fn alloc(&'a self, value: EnumSubtype<'t>) -> &'a mut EnumSubtype<'t>
Allocate a value of type T
.
sourceimpl<'a, 't> Alloc<'a, 'a, ScalarSubtype<'t, dyn FloatingType + 't, f64>> for TypeArena<'t> where
't: 'a,
impl<'a, 't> Alloc<'a, 'a, ScalarSubtype<'t, dyn FloatingType + 't, f64>> for TypeArena<'t> where
't: 'a,
sourcefn alloc(&'a self, value: FloatingSubtype<'t>) -> &'a mut FloatingSubtype<'t>
fn alloc(&'a self, value: FloatingSubtype<'t>) -> &'a mut FloatingSubtype<'t>
Allocate a value of type T
.
sourceimpl<'a, 't> Alloc<'a, 'a, ScalarSubtype<'t, dyn IntegerType + 't, BigInt>> for TypeArena<'t> where
't: 'a,
impl<'a, 't> Alloc<'a, 'a, ScalarSubtype<'t, dyn IntegerType + 't, BigInt>> for TypeArena<'t> where
't: 'a,
sourcefn alloc(&'a self, value: IntegerSubtype<'t>) -> &'a mut IntegerSubtype<'t>
fn alloc(&'a self, value: IntegerSubtype<'t>) -> &'a mut IntegerSubtype<'t>
Allocate a value of type T
.
sourceimpl<'a, 't> Alloc<'a, 'a, ScalarSubtype<'t, dyn PhysicalType + 't, BigInt>> for TypeArena<'t> where
't: 'a,
impl<'a, 't> Alloc<'a, 'a, ScalarSubtype<'t, dyn PhysicalType + 't, BigInt>> for TypeArena<'t> where
't: 'a,
sourcefn alloc(&'a self, value: PhysicalSubtype<'t>) -> &'a mut PhysicalSubtype<'t>
fn alloc(&'a self, value: PhysicalSubtype<'t>) -> &'a mut PhysicalSubtype<'t>
Allocate a value of type T
.
sourceimpl<'t, T: PartialEq + Type + ?Sized + 't, C: PartialEq + Clone> PartialEq<ScalarSubtype<'t, T, C>> for ScalarSubtype<'t, T, C>
impl<'t, T: PartialEq + Type + ?Sized + 't, C: PartialEq + Clone> PartialEq<ScalarSubtype<'t, T, C>> for ScalarSubtype<'t, T, C>
sourcefn eq(&self, other: &ScalarSubtype<'t, T, C>) -> bool
fn eq(&self, other: &ScalarSubtype<'t, T, C>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &ScalarSubtype<'t, T, C>) -> bool
fn ne(&self, other: &ScalarSubtype<'t, T, C>) -> bool
This method tests for !=
.
impl<'t, T: Type + ?Sized + 't + PartialEq, C: Clone + PartialEq> Eq for ScalarSubtype<'t, T, C>
impl<'t, T: Type + ?Sized + 't, C: Clone> StructuralPartialEq for ScalarSubtype<'t, T, C>
Auto Trait Implementations
impl<'t, T, C> !RefUnwindSafe for ScalarSubtype<'t, T, C>
impl<'t, T, C> !Send for ScalarSubtype<'t, T, C>
impl<'t, T, C> !Sync for ScalarSubtype<'t, T, C>
impl<'t, T: ?Sized, C> Unpin for ScalarSubtype<'t, T, C> where
C: Unpin,
impl<'t, T, C> !UnwindSafe for ScalarSubtype<'t, T, C>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more