Struct ckb_rational::RationalU256
source · [−]pub struct RationalU256 { /* private fields */ }
Expand description
Represents the ratio numerator / denominator
, where numerator
and denominator
are both
unsigned 256-bit integers.
Implementations
sourceimpl RationalU256
impl RationalU256
sourcepub fn new(numer: U256, denom: U256) -> RationalU256
pub fn new(numer: U256, denom: U256) -> RationalU256
sourcepub const fn new_raw(numer: U256, denom: U256) -> RationalU256
pub const fn new_raw(numer: U256, denom: U256) -> RationalU256
Creates a new ratio numer / denom
without checking whether denom
is zero.
sourcepub const fn from_u256(t: U256) -> RationalU256
pub const fn from_u256(t: U256) -> RationalU256
Creates a new ratio t / 1
.
sourcepub const fn zero() -> RationalU256
pub const fn zero() -> RationalU256
Creates a new ratio 0 / 1
.
sourcepub const fn one() -> RationalU256
pub const fn one() -> RationalU256
Creates a new ratio 1 / 1
.
sourcepub fn saturating_sub(self, rhs: RationalU256) -> Self
pub fn saturating_sub(self, rhs: RationalU256) -> Self
Computes self - rhs
and saturates the result to zero when self
is less than rhs
.
Returns self - rhs
when self > rhs
, returns zero otherwise.
sourcepub fn saturating_sub_u256(self, rhs: U256) -> Self
pub fn saturating_sub_u256(self, rhs: U256) -> Self
Computes self - rhs
and saturates the result to zero when self
is less than rhs
.
Returns self - rhs
when self > rhs
, returns zero otherwise.
Trait Implementations
sourceimpl Add<&RationalU256> for &RationalU256
impl Add<&RationalU256> for &RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the +
operator.
sourcefn add(self, rhs: &RationalU256) -> RationalU256
fn add(self, rhs: &RationalU256) -> RationalU256
Performs the +
operation. Read more
sourceimpl Add<&RationalU256> for RationalU256
impl Add<&RationalU256> for RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the +
operator.
sourcefn add(self, rhs: &RationalU256) -> RationalU256
fn add(self, rhs: &RationalU256) -> RationalU256
Performs the +
operation. Read more
sourceimpl Add<&U256> for &RationalU256
impl Add<&U256> for &RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the +
operator.
sourcefn add(self, rhs: &U256) -> RationalU256
fn add(self, rhs: &U256) -> RationalU256
Performs the +
operation. Read more
sourceimpl Add<&U256> for RationalU256
impl Add<&U256> for RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the +
operator.
sourcefn add(self, rhs: &U256) -> RationalU256
fn add(self, rhs: &U256) -> RationalU256
Performs the +
operation. Read more
sourceimpl Add<RationalU256> for &RationalU256
impl Add<RationalU256> for &RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the +
operator.
sourcefn add(self, rhs: RationalU256) -> RationalU256
fn add(self, rhs: RationalU256) -> RationalU256
Performs the +
operation. Read more
sourceimpl Add<RationalU256> for RationalU256
impl Add<RationalU256> for RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the +
operator.
sourcefn add(self, rhs: RationalU256) -> RationalU256
fn add(self, rhs: RationalU256) -> RationalU256
Performs the +
operation. Read more
sourceimpl Add<U256> for &RationalU256
impl Add<U256> for &RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the +
operator.
sourcefn add(self, rhs: U256) -> RationalU256
fn add(self, rhs: U256) -> RationalU256
Performs the +
operation. Read more
sourceimpl Add<U256> for RationalU256
impl Add<U256> for RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the +
operator.
sourcefn add(self, rhs: U256) -> RationalU256
fn add(self, rhs: U256) -> RationalU256
Performs the +
operation. Read more
sourceimpl Clone for RationalU256
impl Clone for RationalU256
sourcefn clone(&self) -> RationalU256
fn clone(&self) -> RationalU256
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 RationalU256
impl Debug for RationalU256
sourceimpl<'de> Deserialize<'de> for RationalU256
impl<'de> Deserialize<'de> for RationalU256
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Display for RationalU256
impl Display for RationalU256
sourceimpl Div<&RationalU256> for &RationalU256
impl Div<&RationalU256> for &RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the /
operator.
sourcefn div(self, rhs: &RationalU256) -> RationalU256
fn div(self, rhs: &RationalU256) -> RationalU256
Performs the /
operation. Read more
sourceimpl Div<&RationalU256> for RationalU256
impl Div<&RationalU256> for RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the /
operator.
sourcefn div(self, rhs: &RationalU256) -> RationalU256
fn div(self, rhs: &RationalU256) -> RationalU256
Performs the /
operation. Read more
sourceimpl Div<&U256> for &RationalU256
impl Div<&U256> for &RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the /
operator.
sourcefn div(self, rhs: &U256) -> RationalU256
fn div(self, rhs: &U256) -> RationalU256
Performs the /
operation. Read more
sourceimpl Div<&U256> for RationalU256
impl Div<&U256> for RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the /
operator.
sourcefn div(self, rhs: &U256) -> RationalU256
fn div(self, rhs: &U256) -> RationalU256
Performs the /
operation. Read more
sourceimpl Div<RationalU256> for &RationalU256
impl Div<RationalU256> for &RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the /
operator.
sourcefn div(self, rhs: RationalU256) -> RationalU256
fn div(self, rhs: RationalU256) -> RationalU256
Performs the /
operation. Read more
sourceimpl Div<RationalU256> for RationalU256
impl Div<RationalU256> for RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the /
operator.
sourcefn div(self, rhs: RationalU256) -> RationalU256
fn div(self, rhs: RationalU256) -> RationalU256
Performs the /
operation. Read more
sourceimpl Div<U256> for &RationalU256
impl Div<U256> for &RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the /
operator.
sourcefn div(self, rhs: U256) -> RationalU256
fn div(self, rhs: U256) -> RationalU256
Performs the /
operation. Read more
sourceimpl Div<U256> for RationalU256
impl Div<U256> for RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the /
operator.
sourcefn div(self, rhs: U256) -> RationalU256
fn div(self, rhs: U256) -> RationalU256
Performs the /
operation. Read more
sourceimpl Mul<&RationalU256> for &RationalU256
impl Mul<&RationalU256> for &RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the *
operator.
sourcefn mul(self, rhs: &RationalU256) -> RationalU256
fn mul(self, rhs: &RationalU256) -> RationalU256
Performs the *
operation. Read more
sourceimpl Mul<&RationalU256> for RationalU256
impl Mul<&RationalU256> for RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the *
operator.
sourcefn mul(self, rhs: &RationalU256) -> RationalU256
fn mul(self, rhs: &RationalU256) -> RationalU256
Performs the *
operation. Read more
sourceimpl Mul<&U256> for &RationalU256
impl Mul<&U256> for &RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the *
operator.
sourcefn mul(self, rhs: &U256) -> RationalU256
fn mul(self, rhs: &U256) -> RationalU256
Performs the *
operation. Read more
sourceimpl Mul<&U256> for RationalU256
impl Mul<&U256> for RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the *
operator.
sourcefn mul(self, rhs: &U256) -> RationalU256
fn mul(self, rhs: &U256) -> RationalU256
Performs the *
operation. Read more
sourceimpl Mul<RationalU256> for &RationalU256
impl Mul<RationalU256> for &RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the *
operator.
sourcefn mul(self, rhs: RationalU256) -> RationalU256
fn mul(self, rhs: RationalU256) -> RationalU256
Performs the *
operation. Read more
sourceimpl Mul<RationalU256> for RationalU256
impl Mul<RationalU256> for RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the *
operator.
sourcefn mul(self, rhs: RationalU256) -> RationalU256
fn mul(self, rhs: RationalU256) -> RationalU256
Performs the *
operation. Read more
sourceimpl Mul<U256> for &RationalU256
impl Mul<U256> for &RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the *
operator.
sourcefn mul(self, rhs: U256) -> RationalU256
fn mul(self, rhs: U256) -> RationalU256
Performs the *
operation. Read more
sourceimpl Mul<U256> for RationalU256
impl Mul<U256> for RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the *
operator.
sourcefn mul(self, rhs: U256) -> RationalU256
fn mul(self, rhs: U256) -> RationalU256
Performs the *
operation. Read more
sourceimpl Ord for RationalU256
impl Ord for RationalU256
sourcefn cmp(&self, other: &RationalU256) -> Ordering
fn cmp(&self, other: &RationalU256) -> Ordering
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialEq<RationalU256> for RationalU256
impl PartialEq<RationalU256> for RationalU256
sourcefn eq(&self, other: &RationalU256) -> bool
fn eq(&self, other: &RationalU256) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourceimpl PartialOrd<RationalU256> for RationalU256
impl PartialOrd<RationalU256> for RationalU256
sourcefn partial_cmp(&self, other: &RationalU256) -> Option<Ordering>
fn partial_cmp(&self, other: &RationalU256) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl Serialize for RationalU256
impl Serialize for RationalU256
sourceimpl Sub<&RationalU256> for &RationalU256
impl Sub<&RationalU256> for &RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the -
operator.
sourcefn sub(self, rhs: &RationalU256) -> RationalU256
fn sub(self, rhs: &RationalU256) -> RationalU256
Performs the -
operation. Read more
sourceimpl Sub<&RationalU256> for RationalU256
impl Sub<&RationalU256> for RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the -
operator.
sourcefn sub(self, rhs: &RationalU256) -> RationalU256
fn sub(self, rhs: &RationalU256) -> RationalU256
Performs the -
operation. Read more
sourceimpl Sub<&U256> for &RationalU256
impl Sub<&U256> for &RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the -
operator.
sourcefn sub(self, rhs: &U256) -> RationalU256
fn sub(self, rhs: &U256) -> RationalU256
Performs the -
operation. Read more
sourceimpl Sub<&U256> for RationalU256
impl Sub<&U256> for RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the -
operator.
sourcefn sub(self, rhs: &U256) -> RationalU256
fn sub(self, rhs: &U256) -> RationalU256
Performs the -
operation. Read more
sourceimpl Sub<RationalU256> for &RationalU256
impl Sub<RationalU256> for &RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the -
operator.
sourcefn sub(self, rhs: RationalU256) -> RationalU256
fn sub(self, rhs: RationalU256) -> RationalU256
Performs the -
operation. Read more
sourceimpl Sub<RationalU256> for RationalU256
impl Sub<RationalU256> for RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the -
operator.
sourcefn sub(self, rhs: RationalU256) -> RationalU256
fn sub(self, rhs: RationalU256) -> RationalU256
Performs the -
operation. Read more
sourceimpl Sub<U256> for &RationalU256
impl Sub<U256> for &RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the -
operator.
sourcefn sub(self, rhs: U256) -> RationalU256
fn sub(self, rhs: U256) -> RationalU256
Performs the -
operation. Read more
sourceimpl Sub<U256> for RationalU256
impl Sub<U256> for RationalU256
type Output = RationalU256
type Output = RationalU256
The resulting type after applying the -
operator.
sourcefn sub(self, rhs: U256) -> RationalU256
fn sub(self, rhs: U256) -> RationalU256
Performs the -
operation. Read more
impl Eq for RationalU256
impl StructuralEq for RationalU256
impl StructuralPartialEq for RationalU256
Auto Trait Implementations
impl RefUnwindSafe for RationalU256
impl Send for RationalU256
impl Sync for RationalU256
impl Unpin for RationalU256
impl UnwindSafe for RationalU256
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more