Struct moore_vhdl::ty2::IntegerBasetype
source · [−]pub struct IntegerBasetype { /* private fields */ }
Expand description
An integer base type.
Implementations
sourceimpl IntegerBasetype
impl IntegerBasetype
sourcepub fn new(range: Range<BigInt>) -> IntegerBasetype
pub fn new(range: Range<BigInt>) -> IntegerBasetype
Create a new integer type.
Example
use moore_vhdl::ty2::{Type, IntegerBasetype, Range, RangeDir};
use num::BigInt;
let a = IntegerBasetype::new(Range::ascending(0, 42));
let b = IntegerBasetype::new(Range::descending(42, 0));
assert_eq!(format!("{}", a), "0 to 42");
assert_eq!(format!("{}", b), "42 downto 0");
assert_eq!(a.dir(), RangeDir::To);
assert_eq!(b.dir(), RangeDir::Downto);
assert_eq!(a.len(), BigInt::from(43));
assert_eq!(b.len(), BigInt::from(43));
Methods from Deref<Target = Range<BigInt>>
sourcepub fn dir(&self) -> RangeDir
pub fn dir(&self) -> RangeDir
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);
sourcepub fn left(&self) -> &T
pub fn left(&self) -> &T
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));
sourcepub fn right(&self) -> &T
pub fn right(&self) -> &T
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));
sourcepub fn lower(&self) -> &T
pub fn lower(&self) -> &T
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));
sourcepub fn upper(&self) -> &T
pub fn upper(&self) -> &T
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));
sourcepub fn is_null(&self) -> bool
pub fn is_null(&self) -> bool
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);
sourcepub fn len(&self) -> T
pub fn len(&self) -> T
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));
sourcepub fn has_subrange(&self, subrange: &Self) -> bool
pub fn has_subrange(&self, subrange: &Self) -> bool
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);
Trait Implementations
sourceimpl<'a, 't> Alloc<'a, 'a, IntegerBasetype> for TypeArena<'t> where
't: 'a,
impl<'a, 't> Alloc<'a, 'a, IntegerBasetype> for TypeArena<'t> where
't: 'a,
sourcefn alloc(&'a self, value: IntegerBasetype) -> &'a mut IntegerBasetype
fn alloc(&'a self, value: IntegerBasetype) -> &'a mut IntegerBasetype
Allocate a value of type T
.
sourceimpl Clone for IntegerBasetype
impl Clone for IntegerBasetype
sourcefn clone(&self) -> IntegerBasetype
fn clone(&self) -> IntegerBasetype
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for IntegerBasetype
impl Debug for IntegerBasetype
sourceimpl Deref for IntegerBasetype
impl Deref for IntegerBasetype
sourceimpl Display for IntegerBasetype
impl Display for IntegerBasetype
sourceimpl Hash for IntegerBasetype
impl Hash for IntegerBasetype
sourceimpl IntegerType for IntegerBasetype
impl IntegerType for IntegerBasetype
sourcefn range(&self) -> Option<&Range<BigInt>>
fn range(&self) -> Option<&Range<BigInt>>
The range of values this integer can assume. Read more
sourcefn as_basetype(&self) -> Option<&IntegerBasetype>
fn as_basetype(&self) -> Option<&IntegerBasetype>
Returns Some
if self is an IntegerBasetype
, 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_subtype(&self) -> Option<&IntegerSubtype<'_>>
fn as_subtype(&self) -> Option<&IntegerSubtype<'_>>
Returns Some
if self is an IntegerSubtype
, 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 PartialEq<IntegerBasetype> for IntegerBasetype
impl PartialEq<IntegerBasetype> for IntegerBasetype
sourcefn eq(&self, other: &IntegerBasetype) -> bool
fn eq(&self, other: &IntegerBasetype) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &IntegerBasetype) -> bool
fn ne(&self, other: &IntegerBasetype) -> bool
This method tests for !=
.
sourceimpl Type for IntegerBasetype
impl Type for IntegerBasetype
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.
impl Eq for IntegerBasetype
impl StructuralEq for IntegerBasetype
impl StructuralPartialEq for IntegerBasetype
Auto Trait Implementations
impl RefUnwindSafe for IntegerBasetype
impl Send for IntegerBasetype
impl Sync for IntegerBasetype
impl Unpin for IntegerBasetype
impl UnwindSafe for IntegerBasetype
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