Struct ketos::integer::Ratio [] [src]

pub struct Ratio(_);

Arbitrary precision signed integer ratio

Methods

impl Ratio
[src]

fn new(numer: Integer, denom: Integer) -> Ratio

Constructs a Ratio from numerator and denominator.

Panics

Panics if denom is zero.

fn from_f32(f: f32) -> Option<Ratio>

Creates a Ratio with the value of the given f32. Returns None if the value cannot be converted.

fn from_f64(f: f64) -> Option<Ratio>

Creates a Ratio with the value of the given f64. Returns None if the value cannot be converted.

fn from_integer(i: Integer) -> Ratio

Creates a Ratio from an Integer value.

fn to_f32(&self) -> Option<f32>

Returns the Ratio as an f32 value.

fn to_f64(&self) -> Option<f64>

Returns the Ratio as an f64 value.

fn to_integer(&self) -> Integer

Truncates a Ratio and returns the whole portion as an Integer.

fn is_integer(&self) -> bool

Returns whether the Ratio is an integer; i.e. its denominator is 1.

fn abs(&self) -> Ratio

Returns the absolute value of the Ratio.

fn ceil(&self) -> Ratio

Returns the Ratio rounded towards positive infinity.

fn floor(&self) -> Ratio

Returns the Ratio rounded towards negative infinity.

fn fract(&self) -> Ratio

Returns the fractional portion of a Ratio.

fn round(&self) -> Ratio

Returns the Ratio rounded to the nearest integer. Rounds half-way cases away from zero.

fn trunc(&self) -> Ratio

Returns the Ratio rounded towards zero.

fn recip(&self) -> Ratio

Returns the reciprocal of a Ratio.

Panics

Panics if the numerator is zero.

fn numer(&self) -> &Integer

Returns the Ratio's numerator.

fn denom(&self) -> &Integer

Returns the Ratio's denominator.

fn is_zero(&self) -> bool

Returns whether the Ratio is equal to zero.

fn is_negative(&self) -> bool

Returns whether the Ratio is less than zero.

fn is_positive(&self) -> bool

Returns whether the Ratio is greater than zero.

fn zero() -> Ratio

Returns a Ratio of value zero.

fn one() -> Ratio

Returns a Ratio of value one.

Trait Implementations

impl PartialOrd for Ratio
[src]

fn partial_cmp(&self, __arg_0: &Ratio) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more

fn lt(&self, __arg_0: &Ratio) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more

fn le(&self, __arg_0: &Ratio) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

fn gt(&self, __arg_0: &Ratio) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more

fn ge(&self, __arg_0: &Ratio) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Ord for Ratio
[src]

fn cmp(&self, __arg_0: &Ratio) -> Ordering

This method returns an Ordering between self and other. Read more

impl PartialEq for Ratio
[src]

fn eq(&self, __arg_0: &Ratio) -> bool

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

fn ne(&self, __arg_0: &Ratio) -> bool

This method tests for !=.

impl Eq for Ratio
[src]

impl Debug for Ratio
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl Clone for Ratio
[src]

fn clone(&self) -> Ratio

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more

impl PartialEq<Integer> for Ratio
[src]

fn eq(&self, rhs: &Integer) -> bool

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

fn ne(&self, rhs: &Integer) -> bool

This method tests for !=.

impl Add<Ratio> for Ratio
[src]

type Output = Ratio

The resulting type after applying the + operator

fn add(self, rhs: Ratio) -> Ratio

The method for the + operator

impl<'a> Add<&'a Ratio> for Ratio
[src]

type Output = Ratio

The resulting type after applying the + operator

fn add(self, rhs: &Ratio) -> Ratio

The method for the + operator

impl<'a> Add<Ratio> for &'a Ratio
[src]

type Output = Ratio

The resulting type after applying the + operator

fn add(self, rhs: Ratio) -> Ratio

The method for the + operator

impl<'a, 'b> Add<&'a Ratio> for &'b Ratio
[src]

type Output = Ratio

The resulting type after applying the + operator

fn add(self, rhs: &Ratio) -> Ratio

The method for the + operator

impl Sub<Ratio> for Ratio
[src]

type Output = Ratio

The resulting type after applying the - operator

fn sub(self, rhs: Ratio) -> Ratio

The method for the - operator

impl<'a> Sub<&'a Ratio> for Ratio
[src]

type Output = Ratio

The resulting type after applying the - operator

fn sub(self, rhs: &Ratio) -> Ratio

The method for the - operator

impl<'a> Sub<Ratio> for &'a Ratio
[src]

type Output = Ratio

The resulting type after applying the - operator

fn sub(self, rhs: Ratio) -> Ratio

The method for the - operator

impl<'a, 'b> Sub<&'a Ratio> for &'b Ratio
[src]

type Output = Ratio

The resulting type after applying the - operator

fn sub(self, rhs: &Ratio) -> Ratio

The method for the - operator

impl Mul<Ratio> for Ratio
[src]

type Output = Ratio

The resulting type after applying the * operator

fn mul(self, rhs: Ratio) -> Ratio

The method for the * operator

impl<'a> Mul<&'a Ratio> for Ratio
[src]

type Output = Ratio

The resulting type after applying the * operator

fn mul(self, rhs: &Ratio) -> Ratio

The method for the * operator

impl<'a> Mul<Ratio> for &'a Ratio
[src]

type Output = Ratio

The resulting type after applying the * operator

fn mul(self, rhs: Ratio) -> Ratio

The method for the * operator

impl<'a, 'b> Mul<&'a Ratio> for &'b Ratio
[src]

type Output = Ratio

The resulting type after applying the * operator

fn mul(self, rhs: &Ratio) -> Ratio

The method for the * operator

impl Div<Ratio> for Ratio
[src]

type Output = Ratio

The resulting type after applying the / operator

fn div(self, rhs: Ratio) -> Ratio

The method for the / operator

impl<'a> Div<&'a Ratio> for Ratio
[src]

type Output = Ratio

The resulting type after applying the / operator

fn div(self, rhs: &Ratio) -> Ratio

The method for the / operator

impl<'a> Div<Ratio> for &'a Ratio
[src]

type Output = Ratio

The resulting type after applying the / operator

fn div(self, rhs: Ratio) -> Ratio

The method for the / operator

impl<'a, 'b> Div<&'a Ratio> for &'b Ratio
[src]

type Output = Ratio

The resulting type after applying the / operator

fn div(self, rhs: &Ratio) -> Ratio

The method for the / operator

impl Rem<Ratio> for Ratio
[src]

type Output = Ratio

The resulting type after applying the % operator

fn rem(self, rhs: Ratio) -> Ratio

The method for the % operator

impl<'a> Rem<&'a Ratio> for Ratio
[src]

type Output = Ratio

The resulting type after applying the % operator

fn rem(self, rhs: &Ratio) -> Ratio

The method for the % operator

impl<'a> Rem<Ratio> for &'a Ratio
[src]

type Output = Ratio

The resulting type after applying the % operator

fn rem(self, rhs: Ratio) -> Ratio

The method for the % operator

impl<'a, 'b> Rem<&'a Ratio> for &'b Ratio
[src]

type Output = Ratio

The resulting type after applying the % operator

fn rem(self, rhs: &Ratio) -> Ratio

The method for the % operator

impl Neg for Ratio
[src]

type Output = Ratio

The resulting type after applying the - operator

fn neg(self) -> Ratio

The method for the unary - operator

impl<'a> Neg for &'a Ratio
[src]

type Output = Ratio

The resulting type after applying the - operator

fn neg(self) -> Ratio

The method for the unary - operator

impl Zero for Ratio
[src]

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.

fn zero() -> Ratio

Returns the additive identity element of Self, 0. Read more

impl Display for Ratio
[src]

fn fmt(&self, f: &mut Formatter) -> Result

Formats the value using the given formatter.

impl FromStr for Ratio
[src]

type Err = FromStrRatioError

The associated error which can be returned from parsing.

fn from_str(s: &str) -> Result<RatioFromStrRatioError>

Parses a string s to return a value of this type. Read more

impl<'a> FromValueRef<'a> for &'a Ratio
[src]

fn from_value_ref(v: &'a Value) -> Result<&'a RatioExecError>

Returns the borrowed value

impl FromValue for Ratio
[src]

fn from_value(v: Value) -> Result<RatioExecError>

Consumes the Value and returns a Rust value