pub enum NumericDomain {
Unsigned {
bits: u32,
},
Signed {
bits: u32,
},
Float {
mantissa: u32,
exponent: u32,
},
}Expand description
The set of numbers a scalar port type can carry, described by the properties that decide whether one of them holds every value of another: how many bits the representation has, and how it spends them.
Bool is the one-bit unsigned domain, which is what the type
system already says of it — it widens to U64 as 1 and 0.
Non-scalar types (Str, Bytes, Json, the vectors, the
register views, Ext, Handle) have no domain.
Variants§
Unsigned
Non-negative integers in 0 ..= 2^bits - 1.
Signed
Two’s-complement integers, one of whose bits is the sign.
Float
An IEEE 754 binary float.
Implementations§
Source§impl NumericDomain
impl NumericDomain
Sourcepub fn fits_in(self, other: NumericDomain) -> bool
pub fn fits_in(self, other: NumericDomain) -> bool
Whether every value of this domain is a value of other —
that is, whether a conversion into other is lossless.
Integers fit by counting the bits each spends on magnitude: an
unsigned domain needs a signed one strictly wider, a signed
domain never fits an unsigned one. An integer fits a float
when its magnitude bits fit the float’s significand, which is
why U64 → F64 does not: 64 magnitude bits do not fit 53, and
the values above 2^53 round. A float fits a wider float when
both its significand and its exponent do.
Trait Implementations§
Source§impl Clone for NumericDomain
impl Clone for NumericDomain
Source§fn clone(&self) -> NumericDomain
fn clone(&self) -> NumericDomain
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for NumericDomain
Source§impl Debug for NumericDomain
impl Debug for NumericDomain
impl Eq for NumericDomain
Source§impl PartialEq for NumericDomain
impl PartialEq for NumericDomain
impl StructuralPartialEq for NumericDomain
Auto Trait Implementations§
impl Freeze for NumericDomain
impl RefUnwindSafe for NumericDomain
impl Send for NumericDomain
impl Sync for NumericDomain
impl Unpin for NumericDomain
impl UnsafeUnpin for NumericDomain
impl UnwindSafe for NumericDomain
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more