Struct sc_network::multiaddr::multihash::typenum::uint::UInt [−]
pub struct UInt<U, B> { /* fields omitted */ }
Expand description
UInt
is defined recursively, where B
is the least significant bit and U
is the rest
of the number. Conceptually, U
should be bound by the trait Unsigned
and B
should
be bound by the trait Bit
, but enforcing these bounds causes linear instead of
logrithmic scaling in some places, so they are left off for now. They may be enforced in
future.
In order to keep numbers unique, leading zeros are not allowed, so UInt<UTerm, B0>
is
forbidden.
Example
use typenum::{B0, B1, UInt, UTerm}; type U6 = UInt<UInt<UInt<UTerm, B1>, B1>, B0>;
Implementations
Trait Implementations
U + B0 = U
UInt<U, B1> + B1 = UInt<U + B1, B0>
UInt<U, B0> + B1 = UInt<U + B1>
UInt<Ul, B1> + UInt<Ur, B0> = UInt<Ul + Ur, B1>
UInt<Ul, B0> + UInt<Ur, B0> = UInt<Ul + Ur, B0>
UInt<Ul, B1> + UInt<Ur, B1> = UInt<(Ul + Ur) + B1, B0>
UInt<Ul, B0> + UInt<Ur, B1> = UInt<Ul + Ur, B1>
UInt<U, B> + UTerm = UInt<U, B>
type ArrayType
type ArrayType
Associated type representing the array type for the number
type ArrayType
type ArrayType
Associated type representing the array type for the number
type ArrayType
type ArrayType
Associated type representing the array type for the number
type ArrayType
type ArrayType
Associated type representing the array type for the number
Anding unsigned integers.
We use our PrivateAnd
operator and then Trim
the output.
UInt<Ul, B1> | UInt<Ur, B0> = UInt<Ul | Ur, B1>
UInt<Ul, B0> | UInt<Ur, B0> = UInt<Ul | Ur, B0>
UInt<Ul, B0> | UInt<Ur, B1> = UInt<Ul | Ur, B1>
UInt<Ul, B1> | UInt<Ur, B1> = UInt<Ul | Ur, B1>
X | UTerm = X
Xoring unsigned integers.
We use our PrivateXor
operator and then Trim
the output.
Zero < Nonzero
UInt<Ul, B1>
cmp with UInt<Ur, B0>
: SoFar
is Greater
UInt<Ul, B0>
cmp with UInt<Ur, B0>
: SoFar
is Equal
UInt<Ul, B1>
cmp with UInt<Ur, B1>
: SoFar
is Equal
UInt<Ul, B0>
cmp with UInt<Ur, B1>
: SoFar
is Less
Nonzero > Zero
The resulting type after applying the /
operator.
gcd(x, y) = 2*gcd(x/2, y/2) if both x and y even
gcd(x, y) = gcd(x, y/2) if x odd and y even
impl<Xp, Yp> Gcd<UInt<Yp, B1>> for UInt<Xp, B1> where
UInt<Xp, B1>: Max<UInt<Yp, B1>>,
UInt<Xp, B1>: Min<UInt<Yp, B1>>,
UInt<Yp, B1>: Max<UInt<Xp, B1>>,
UInt<Yp, B1>: Min<UInt<Xp, B1>>,
<UInt<Xp, B1> as Max<UInt<Yp, B1>>>::Output: Sub<<UInt<Xp, B1> as Min<UInt<Yp, B1>>>::Output>,
<<UInt<Xp, B1> as Max<UInt<Yp, B1>>>::Output as Sub<<UInt<Xp, B1> as Min<UInt<Yp, B1>>>::Output>>::Output: Gcd<<UInt<Xp, B1> as Min<UInt<Yp, B1>>>::Output>,
impl<Xp, Yp> Gcd<UInt<Yp, B1>> for UInt<Xp, B1> where
UInt<Xp, B1>: Max<UInt<Yp, B1>>,
UInt<Xp, B1>: Min<UInt<Yp, B1>>,
UInt<Yp, B1>: Max<UInt<Xp, B1>>,
UInt<Yp, B1>: Min<UInt<Xp, B1>>,
<UInt<Xp, B1> as Max<UInt<Yp, B1>>>::Output: Sub<<UInt<Xp, B1> as Min<UInt<Yp, B1>>>::Output>,
<<UInt<Xp, B1> as Max<UInt<Yp, B1>>>::Output as Sub<<UInt<Xp, B1> as Min<UInt<Yp, B1>>>::Output>>::Output: Gcd<<UInt<Xp, B1> as Min<UInt<Yp, B1>>>::Output>,
gcd(x, y) = gcd([max(x, y) - min(x, y)], min(x, y)) if both x and y odd
This will immediately invoke the case for x even and y odd because the difference of two odd numbers is an even number.
gcd(x, y) = gcd(x/2, y) if x even and y odd
Length of a bit is 1
UInt * B0 = UTerm
UInt * B1 = UInt
UInt<Ul, B0> * UInt<Ur, B> = UInt<(Ul * UInt<Ur, B>), B0>
UInt<Ul, B1> * UInt<Ur, B> = UInt<(Ul * UInt<Ur, B>), B0> + UInt<Ur, B>
UInt<U, B> * UTerm = UTerm
impl<Ur, Br> PartialDiv<UInt<Ur, Br>> for UTerm where
Br: Bit,
Ur: Unsigned,
impl<Ur, Br> PartialDiv<UInt<Ur, Br>> for UTerm where
Br: Bit,
Ur: Unsigned,
pub fn partial_div(
self,
UInt<Ur, Br>
) -> <UTerm as PartialDiv<UInt<Ur, Br>>>::Output
pub fn partial_div(
self,
UInt<Ur, Br>
) -> <UTerm as PartialDiv<UInt<Ur, Br>>>::Output
Method for performing the division
impl<U, B> PartialOrd<UInt<U, B>> for UInt<U, B> where
B: PartialOrd<B>,
U: PartialOrd<U>,
impl<U, B> PartialOrd<UInt<U, B>> for UInt<U, B> where
B: PartialOrd<B>,
U: PartialOrd<U>,
pub fn partial_cmp(&self, other: &UInt<U, B>) -> Option<Ordering>
pub fn partial_cmp(&self, other: &UInt<U, B>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
The resulting type after applying the %
operator.
Shifting left any unsigned by a zero bit: U << B0 = U
Shifting left a UInt
by a one bit: UInt<U, B> << B1 = UInt<UInt<U, B>, B0>
Shifting left UInt
by UInt
: X << Y
= UInt(X, B0) << (Y - 1)
Shifting left UInt
by UTerm
: UInt<U, B> << UTerm = UInt<U, B>
Shifting right any unsigned by a zero bit: U >> B0 = U
Shifting right a UInt
by a 1 bit: UInt<U, B> >> B1 = U
Shifting right UInt
by UInt
: UInt(U, B) >> Y
= U >> (Y - 1)
Shifting right UInt
by UTerm
: UInt<U, B> >> UTerm = UInt<U, B>
UInt - B0 = UInt
UInt<U, B0> - B1 = UInt<U - B1, B1>
UInt<U, B1> - B1 = UInt<U, B0>
UInt<UTerm, B1> - B1 = UTerm
Subtracting unsigned integers. We just do our PrivateSub
and then Trim
the output.
impl<U> PowerOfTwo for UInt<U, B0> where
U: Unsigned + PowerOfTwo,
impl PowerOfTwo for UInt<UTerm, B1>
impl<U, B> StructuralEq for UInt<U, B>
impl<U, B> StructuralPartialEq for UInt<U, B>
Auto Trait Implementations
impl<U, B> RefUnwindSafe for UInt<U, B> where
B: RefUnwindSafe,
U: RefUnwindSafe,
impl<U, B> UnwindSafe for UInt<U, B> where
B: UnwindSafe,
U: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
impl<T> CallHasher for T where
T: Hash,
impl<T> CallHasher for T where
T: Hash,
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
Convert Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more
Compare self to key
and return true
if they are equal.
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
impl<N> Logarithm2 for N where
N: PrivateLogarithm2,
impl<N> Logarithm2 for N where
N: PrivateLogarithm2,
type Output = <N as PrivateLogarithm2>::Output
type Output = <N as PrivateLogarithm2>::Output
The result of the integer binary logarithm.
impl<N, I, B> SetBit<I, B> for N where
N: PrivateSetBit<I, B>,
<N as PrivateSetBit<I, B>>::Output: Trim,
impl<N, I, B> SetBit<I, B> for N where
N: PrivateSetBit<I, B>,
<N as PrivateSetBit<I, B>>::Output: Trim,
impl<N> SquareRoot for N where
N: PrivateSquareRoot,
impl<N> SquareRoot for N where
N: PrivateSquareRoot,
type Output = <N as PrivateSquareRoot>::Output
type Output = <N as PrivateSquareRoot>::Output
The result of the integer square root.
The counterpart to unchecked_from
.
Consume self to return an equivalent value of T
.
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
impl<T> MaybeDebug for T where
T: Debug,
impl<T> MaybeDebug for T where
T: Debug,
impl<T, Rhs, Output> NumOps<Rhs, Output> for T where
T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,
impl<T> SimpleBitOps for T where
T: BitOr<T, Output = T> + BitXor<T, Output = T> + BitAnd<T, Output = T> + Clear,