Struct moore_vhdl::ty2::PhysicalBasetype[][src]

pub struct PhysicalBasetype { /* fields omitted */ }
Expand description

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

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>>

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);

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));

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));

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));

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));

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);

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));

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);

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

Allocate a value of type T.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Convert to a type.

The range of values this physical type can assume.

The units of measure of this type.

The index of the primary unit.

The base type of this physical type.

Returns Some if self is a PhysicalBasetype, None otherwise.

Check if two physical types are equal.

The resolution function associated with this type.

Returns Some if self is a PhysicalSubtype, None otherwise.

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

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

Check if this is a scalar type. Read more

Check if this is a discrete type. Read more

Check if this is a numeric type. Read more

Check if this is a composite type. Read more

Converts from &Type to AnyType.

Convert into an owned type.

Clone this type.

Check if two types are equal.

Check if the type can be implicitly cast to another.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

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

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.