[−][src]Struct moore_vhdl::ty2::PhysicalBasetype
A physical base type.
In VHDL a physical type is an integer multiple of some measurement unit. A physical type has exactly one primary unit, and multiple secondary units defined as multiples of that primary unit.
Implementations
impl PhysicalBasetype
[src]
pub fn new<I>(
range: Range<BigInt>,
units: I,
primary: usize
) -> PhysicalBasetype where
I: IntoIterator<Item = PhysicalUnit>,
[src]
range: Range<BigInt>,
units: I,
primary: usize
) -> PhysicalBasetype where
I: IntoIterator<Item = PhysicalUnit>,
Create a new physical type.
Example
use moore_vhdl::ty2::{PhysicalBasetype, PhysicalUnit, Range}; use moore_common::name::get_name_table; let ty = PhysicalBasetype::new(Range::ascending(0, 1_000_000), vec![ PhysicalUnit::primary(get_name_table().intern("fs", false), 1), PhysicalUnit::secondary(get_name_table().intern("ps", false), 1_000, 1000, 0), PhysicalUnit::secondary(get_name_table().intern("ns", false), 1_000_000, 1000, 1), ], 0); assert_eq!(format!("{}", ty), "0 to 1000000 units (fs, ps, ns)");
Methods from Deref<Target = Range<BigInt>>
pub fn dir(&self) -> RangeDir
[src]
Return the direction of the range.
Example
use moore_vhdl::ty2::{IntegerRange, RangeDir}; let a = IntegerRange::ascending(0, 42); let b = IntegerRange::descending(42, 0); assert_eq!(a.dir(), RangeDir::To); assert_eq!(b.dir(), RangeDir::Downto);
pub fn left(&self) -> &T
[src]
Return the left bound of the range.
Example
use moore_vhdl::ty2::{IntegerRange, BigInt}; let a = IntegerRange::ascending(0, 42); let b = IntegerRange::descending(42, 0); assert_eq!(a.left(), &BigInt::from(0)); assert_eq!(b.left(), &BigInt::from(42));
pub fn right(&self) -> &T
[src]
Return the right bound of the range.
Example
use moore_vhdl::ty2::{IntegerRange, BigInt}; let a = IntegerRange::ascending(0, 42); let b = IntegerRange::descending(42, 0); assert_eq!(a.right(), &BigInt::from(42)); assert_eq!(b.right(), &BigInt::from(0));
pub fn lower(&self) -> &T
[src]
Return the lower bound of the range.
Example
use moore_vhdl::ty2::{IntegerRange, BigInt}; let a = IntegerRange::ascending(0, 42); let b = IntegerRange::descending(42, 0); assert_eq!(a.lower(), &BigInt::from(0)); assert_eq!(b.lower(), &BigInt::from(0));
pub fn upper(&self) -> &T
[src]
Return the upper bound of the range.
Example
use moore_vhdl::ty2::{IntegerRange, BigInt}; let a = IntegerRange::ascending(0, 42); let b = IntegerRange::descending(42, 0); assert_eq!(a.upper(), &BigInt::from(42)); assert_eq!(b.upper(), &BigInt::from(42));
pub fn is_null(&self) -> bool
[src]
Return true if the range is a null range.
A null range has its lower bound greater than or equal to its upper bound, and thus also a length of 0 or lower.
Example
use moore_vhdl::ty2::IntegerRange; let a = IntegerRange::ascending(0, 42); let b = IntegerRange::ascending(42, 0); assert_eq!(a.is_null(), false); assert_eq!(b.is_null(), true);
pub fn len(&self) -> T
[src]
Return the length of the range.
The length of a range is defined as upper + 1 - lower
. The result may
be negative, indicating that the range is a null range.
Example
use moore_vhdl::ty2::{IntegerRange, BigInt}; let a = IntegerRange::ascending(0, 42); let b = IntegerRange::ascending(42, 0); assert_eq!(a.len(), BigInt::from(43)); assert_eq!(b.len(), BigInt::from(-41));
pub fn has_subrange(&self, subrange: &Self) -> bool
[src]
Check if another range is a subrange of this range.
This function checks if self.lower()
is less than or equal to, and
self.upper()
is larger than or equal to, the corresponding bounds of
the subrange.
Example
use moore_vhdl::ty2::{IntegerRange, BigInt}; let a = IntegerRange::ascending(0, 42); let b = IntegerRange::ascending(4, 16); let c = IntegerRange::descending(16, 4); assert_eq!(a.has_subrange(&b), true); assert_eq!(a.has_subrange(&c), true); assert_eq!(b.has_subrange(&a), false); assert_eq!(c.has_subrange(&a), false); assert_eq!(b.has_subrange(&c), true); assert_eq!(c.has_subrange(&b), true);
pub fn contains(&self, value: &T) -> bool
[src]
Check if a value is within this range.
This function checks if self.lower()
is less than or equal to, and
self.upper()
is larger than or equal to, the given value.
Trait Implementations
impl<'a, 't> Alloc<'a, 'a, PhysicalBasetype> for TypeArena<'t> where
't: 'a,
[src]
't: 'a,
fn alloc(&'a self, value: PhysicalBasetype) -> &'a mut PhysicalBasetype
[src]
impl Clone for PhysicalBasetype
[src]
fn clone(&self) -> PhysicalBasetype
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for PhysicalBasetype
[src]
impl Deref for PhysicalBasetype
[src]
type Target = Range<BigInt>
The resulting type after dereferencing.
fn deref(&self) -> &Range<BigInt>
[src]
impl Display for PhysicalBasetype
[src]
impl Eq for PhysicalBasetype
[src]
impl PartialEq<PhysicalBasetype> for PhysicalBasetype
[src]
fn eq(&self, other: &PhysicalBasetype) -> bool
[src]
fn ne(&self, other: &PhysicalBasetype) -> bool
[src]
impl PhysicalType for PhysicalBasetype
[src]
fn as_type(&self) -> &dyn Type
[src]
fn range(&self) -> &Range<BigInt>
[src]
fn units(&self) -> &[PhysicalUnit]
[src]
fn primary_index(&self) -> usize
[src]
fn base_type(&self) -> &dyn Type
[src]
fn as_basetype(&self) -> Option<&PhysicalBasetype>
[src]
fn is_equal(&self, other: &dyn PhysicalType) -> bool
[src]
fn resolution_func(&self) -> Option<usize>
[src]
fn as_subtype(&self) -> Option<&PhysicalSubtype>
[src]
fn unwrap_basetype(&self) -> &PhysicalBasetype
[src]
fn unwrap_subtype(&self) -> &PhysicalSubtype
[src]
impl StructuralEq for PhysicalBasetype
[src]
impl StructuralPartialEq for PhysicalBasetype
[src]
impl Type for PhysicalBasetype
[src]
fn is_scalar(&self) -> bool
[src]
fn is_discrete(&self) -> bool
[src]
fn is_numeric(&self) -> bool
[src]
fn is_composite(&self) -> bool
[src]
fn as_any(&self) -> AnyType
[src]
fn into_owned<'a>(self) -> OwnedType<'a> where
Self: 'a,
[src]
Self: 'a,
fn to_owned<'a>(&self) -> OwnedType<'a> where
Self: 'a,
[src]
Self: 'a,
fn is_equal(&self, other: &dyn Type) -> bool
[src]
fn is_implicitly_castable(&self, _into: &dyn Type) -> bool
[src]
Auto Trait Implementations
impl RefUnwindSafe for PhysicalBasetype
impl Send for PhysicalBasetype
impl Sync for PhysicalBasetype
impl Unpin for PhysicalBasetype
impl UnwindSafe for PhysicalBasetype
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,