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§
source§impl 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§
source§impl Add<&RationalU256> for &RationalU256
impl Add<&RationalU256> for &RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
+ operator.source§fn add(self, rhs: &RationalU256) -> RationalU256
fn add(self, rhs: &RationalU256) -> RationalU256
Performs the
+ operation. Read moresource§impl Add<&RationalU256> for RationalU256
impl Add<&RationalU256> for RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
+ operator.source§fn add(self, rhs: &RationalU256) -> RationalU256
fn add(self, rhs: &RationalU256) -> RationalU256
Performs the
+ operation. Read moresource§impl Add<&U256> for &RationalU256
impl Add<&U256> for &RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
+ operator.source§fn add(self, rhs: &U256) -> RationalU256
fn add(self, rhs: &U256) -> RationalU256
Performs the
+ operation. Read moresource§impl Add<&U256> for RationalU256
impl Add<&U256> for RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
+ operator.source§fn add(self, rhs: &U256) -> RationalU256
fn add(self, rhs: &U256) -> RationalU256
Performs the
+ operation. Read moresource§impl Add<RationalU256> for &RationalU256
impl Add<RationalU256> for &RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
+ operator.source§fn add(self, rhs: RationalU256) -> RationalU256
fn add(self, rhs: RationalU256) -> RationalU256
Performs the
+ operation. Read moresource§impl Add<RationalU256> for RationalU256
impl Add<RationalU256> for RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
+ operator.source§fn add(self, rhs: RationalU256) -> RationalU256
fn add(self, rhs: RationalU256) -> RationalU256
Performs the
+ operation. Read moresource§impl Add<U256> for &RationalU256
impl Add<U256> for &RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
+ operator.source§fn add(self, rhs: U256) -> RationalU256
fn add(self, rhs: U256) -> RationalU256
Performs the
+ operation. Read moresource§impl Add<U256> for RationalU256
impl Add<U256> for RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
+ operator.source§fn add(self, rhs: U256) -> RationalU256
fn add(self, rhs: U256) -> RationalU256
Performs the
+ operation. Read moresource§impl Clone for RationalU256
impl Clone for RationalU256
source§fn clone(&self) -> RationalU256
fn clone(&self) -> RationalU256
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for RationalU256
impl Debug for RationalU256
source§impl<'de> Deserialize<'de> for RationalU256
impl<'de> Deserialize<'de> for RationalU256
source§fn 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
source§impl Display for RationalU256
impl Display for RationalU256
source§impl Div<&RationalU256> for &RationalU256
impl Div<&RationalU256> for &RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
/ operator.source§fn div(self, rhs: &RationalU256) -> RationalU256
fn div(self, rhs: &RationalU256) -> RationalU256
Performs the
/ operation. Read moresource§impl Div<&RationalU256> for RationalU256
impl Div<&RationalU256> for RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
/ operator.source§fn div(self, rhs: &RationalU256) -> RationalU256
fn div(self, rhs: &RationalU256) -> RationalU256
Performs the
/ operation. Read moresource§impl Div<&U256> for &RationalU256
impl Div<&U256> for &RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
/ operator.source§fn div(self, rhs: &U256) -> RationalU256
fn div(self, rhs: &U256) -> RationalU256
Performs the
/ operation. Read moresource§impl Div<&U256> for RationalU256
impl Div<&U256> for RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
/ operator.source§fn div(self, rhs: &U256) -> RationalU256
fn div(self, rhs: &U256) -> RationalU256
Performs the
/ operation. Read moresource§impl Div<RationalU256> for &RationalU256
impl Div<RationalU256> for &RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
/ operator.source§fn div(self, rhs: RationalU256) -> RationalU256
fn div(self, rhs: RationalU256) -> RationalU256
Performs the
/ operation. Read moresource§impl Div<RationalU256> for RationalU256
impl Div<RationalU256> for RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
/ operator.source§fn div(self, rhs: RationalU256) -> RationalU256
fn div(self, rhs: RationalU256) -> RationalU256
Performs the
/ operation. Read moresource§impl Div<U256> for &RationalU256
impl Div<U256> for &RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
/ operator.source§fn div(self, rhs: U256) -> RationalU256
fn div(self, rhs: U256) -> RationalU256
Performs the
/ operation. Read moresource§impl Div<U256> for RationalU256
impl Div<U256> for RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
/ operator.source§fn div(self, rhs: U256) -> RationalU256
fn div(self, rhs: U256) -> RationalU256
Performs the
/ operation. Read moresource§impl Mul<&RationalU256> for &RationalU256
impl Mul<&RationalU256> for &RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
* operator.source§fn mul(self, rhs: &RationalU256) -> RationalU256
fn mul(self, rhs: &RationalU256) -> RationalU256
Performs the
* operation. Read moresource§impl Mul<&RationalU256> for RationalU256
impl Mul<&RationalU256> for RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
* operator.source§fn mul(self, rhs: &RationalU256) -> RationalU256
fn mul(self, rhs: &RationalU256) -> RationalU256
Performs the
* operation. Read moresource§impl Mul<&U256> for &RationalU256
impl Mul<&U256> for &RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
* operator.source§fn mul(self, rhs: &U256) -> RationalU256
fn mul(self, rhs: &U256) -> RationalU256
Performs the
* operation. Read moresource§impl Mul<&U256> for RationalU256
impl Mul<&U256> for RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
* operator.source§fn mul(self, rhs: &U256) -> RationalU256
fn mul(self, rhs: &U256) -> RationalU256
Performs the
* operation. Read moresource§impl Mul<RationalU256> for &RationalU256
impl Mul<RationalU256> for &RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
* operator.source§fn mul(self, rhs: RationalU256) -> RationalU256
fn mul(self, rhs: RationalU256) -> RationalU256
Performs the
* operation. Read moresource§impl Mul<RationalU256> for RationalU256
impl Mul<RationalU256> for RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
* operator.source§fn mul(self, rhs: RationalU256) -> RationalU256
fn mul(self, rhs: RationalU256) -> RationalU256
Performs the
* operation. Read moresource§impl Mul<U256> for &RationalU256
impl Mul<U256> for &RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
* operator.source§fn mul(self, rhs: U256) -> RationalU256
fn mul(self, rhs: U256) -> RationalU256
Performs the
* operation. Read moresource§impl Mul<U256> for RationalU256
impl Mul<U256> for RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
* operator.source§fn mul(self, rhs: U256) -> RationalU256
fn mul(self, rhs: U256) -> RationalU256
Performs the
* operation. Read moresource§impl Ord for RationalU256
impl Ord for RationalU256
source§fn cmp(&self, other: &RationalU256) -> Ordering
fn cmp(&self, other: &RationalU256) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq<RationalU256> for RationalU256
impl PartialEq<RationalU256> for RationalU256
source§fn 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 ==.source§impl PartialOrd<RationalU256> for RationalU256
impl PartialOrd<RationalU256> for RationalU256
source§fn partial_cmp(&self, other: &RationalU256) -> Option<Ordering>
fn partial_cmp(&self, other: &RationalU256) -> Option<Ordering>
1.0.0 · source§fn 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 moresource§impl Serialize for RationalU256
impl Serialize for RationalU256
source§impl Sub<&RationalU256> for &RationalU256
impl Sub<&RationalU256> for &RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
- operator.source§fn sub(self, rhs: &RationalU256) -> RationalU256
fn sub(self, rhs: &RationalU256) -> RationalU256
Performs the
- operation. Read moresource§impl Sub<&RationalU256> for RationalU256
impl Sub<&RationalU256> for RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
- operator.source§fn sub(self, rhs: &RationalU256) -> RationalU256
fn sub(self, rhs: &RationalU256) -> RationalU256
Performs the
- operation. Read moresource§impl Sub<&U256> for &RationalU256
impl Sub<&U256> for &RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
- operator.source§fn sub(self, rhs: &U256) -> RationalU256
fn sub(self, rhs: &U256) -> RationalU256
Performs the
- operation. Read moresource§impl Sub<&U256> for RationalU256
impl Sub<&U256> for RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
- operator.source§fn sub(self, rhs: &U256) -> RationalU256
fn sub(self, rhs: &U256) -> RationalU256
Performs the
- operation. Read moresource§impl Sub<RationalU256> for &RationalU256
impl Sub<RationalU256> for &RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
- operator.source§fn sub(self, rhs: RationalU256) -> RationalU256
fn sub(self, rhs: RationalU256) -> RationalU256
Performs the
- operation. Read moresource§impl Sub<RationalU256> for RationalU256
impl Sub<RationalU256> for RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
- operator.source§fn sub(self, rhs: RationalU256) -> RationalU256
fn sub(self, rhs: RationalU256) -> RationalU256
Performs the
- operation. Read moresource§impl Sub<U256> for &RationalU256
impl Sub<U256> for &RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
- operator.source§fn sub(self, rhs: U256) -> RationalU256
fn sub(self, rhs: U256) -> RationalU256
Performs the
- operation. Read moresource§impl Sub<U256> for RationalU256
impl Sub<U256> for RationalU256
§type Output = RationalU256
type Output = RationalU256
The resulting type after applying the
- operator.source§fn sub(self, rhs: U256) -> RationalU256
fn sub(self, rhs: U256) -> RationalU256
Performs the
- operation. Read more