[][src]Struct moore_vhdl::ty2::FloatingBasetype

pub struct FloatingBasetype { /* fields omitted */ }

A real base type.

Methods

impl FloatingBasetype
[src]

pub fn new(range: Range<f64>) -> FloatingBasetype
[src]

Create a new real type.

Example

use moore_vhdl::ty2::{Type, FloatingBasetype, Range, RangeDir};

let a = FloatingBasetype::new(Range::ascending(0, 42));
let b = FloatingBasetype::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(), 43 as f64);
assert_eq!(b.len(), 43 as f64);

Methods from Deref<Target = Range<f64>>

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, FloatingBasetype> for TypeArena<'t> where
    't: 'a, 
[src]

impl Type for FloatingBasetype
[src]

fn is_equal(&self, other: &dyn Type) -> bool
[src]

Check if two types are equal.

fn is_implicitly_castable(&self, _into: &dyn Type) -> bool
[src]

Check if the type can be implicitly cast to another.

impl FloatingType for FloatingBasetype
[src]

fn resolution_func(&self) -> Option<usize>
[src]

The resolution function associated with this type.

fn as_subtype(&self) -> Option<&FloatingSubtype>
[src]

Returns Some if self is an FloatingSubtype, None otherwise.

fn is_universal(&self) -> bool
[src]

Checks whether this is a universal real type.

fn unwrap_basetype(&self) -> &FloatingBasetype
[src]

Returns an &FloatingBasetype or panics if the type is not a basetype.

fn unwrap_subtype(&self) -> &FloatingSubtype
[src]

Returns an &FloatingSubtype or panics if the type is not a subtype.

impl Eq for FloatingBasetype
[src]

impl Clone for FloatingBasetype
[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl PartialEq<FloatingBasetype> for FloatingBasetype
[src]

impl Debug for FloatingBasetype
[src]

impl Deref for FloatingBasetype
[src]

type Target = Range<f64>

The resulting type after dereferencing.

impl Display for FloatingBasetype
[src]

Auto Trait Implementations

Blanket Implementations

impl<T> From for T
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.