Trait calc::types::Calcable[][src]

pub trait Calcable: Clone + Display + Add<Output = Self> + Sub<Output = Self> + Mul<Output = Self> + Div<Output = Self> {
    type Err: Error + CalcableError;

    const E: Option<Self>;
    const PI: Option<Self>;

    fn parse_binary(s: &str) -> Result<Self, Self::Err>;
fn parse_octal(s: &str) -> Result<Self, Self::Err>;
fn parse_decimal(s: &str) -> Result<Self, Self::Err>;
fn parse_hex(s: &str) -> Result<Self, Self::Err>;
fn from_f32(f: f32) -> Option<Self>;
fn neg(self) -> Option<Self>;
fn not(self) -> Option<Self>;
fn add(self, other: Self) -> Result<Self, Self::Err>;
fn sub(self, other: Self) -> Result<Self, Self::Err>;
fn mul(self, other: Self) -> Result<Self, Self::Err>;
fn div(self, other: Self) -> Result<Self, Self::Err>;
fn trunc_div(self, other: Self) -> Result<Self, Self::Err>;
fn pow(self, other: Self) -> Result<Self, Self::Err>;
fn rem(self, other: Self) -> Result<Self, Self::Err>;
fn shl(self, other: Self) -> Result<Self, Self::Err>;
fn shr(self, other: Self) -> Result<Self, Self::Err>;
fn rotate_left(self, other: Self) -> Result<Self, Self::Err>;
fn rotate_right(self, other: Self) -> Result<Self, Self::Err>;
fn bit_and(self, other: Self) -> Option<Self>;
fn bit_or(self, other: Self) -> Option<Self>;
fn bit_xor(self, other: Self) -> Option<Self>;
fn abs(self) -> Option<Self>;
fn ceil(self) -> Option<Self>;
fn floor(self) -> Option<Self>;
fn round(self) -> Option<Self>;
fn sin(self) -> Option<Self>;
fn cos(self) -> Option<Self>;
fn tan(self) -> Option<Self>;
fn sinh(self) -> Option<Self>;
fn cosh(self) -> Option<Self>;
fn tanh(self) -> Option<Self>;
fn asin(self) -> Option<Self>;
fn acos(self) -> Option<Self>;
fn atan(self) -> Option<Self>;
fn asinh(self) -> Option<Self>;
fn acosh(self) -> Option<Self>;
fn atanh(self) -> Option<Self>;
fn sqrt(self) -> Option<Self>;
fn cbrt(self) -> Option<Self>;
fn ln(self) -> Option<Self>; fn rad(self) -> Option<Self> { ... }
fn deg(self) -> Option<Self> { ... }
fn log(self) -> Option<Self> { ... }
fn lg(self) -> Option<Self> { ... }
fn exp(self) -> Option<Self> { ... } }

A trait indicating that this type is suitable for usage in this program.

Every type used here has to have basic arithmetic operations defined, but the rest of its behaviors may or may not be defined. Attempts to evaluate an operation which returns None will result in an “unimplemented” error message bubbling up to the user.

Associated Types

Loading content...

Associated Constants

const E: Option<Self>[src]

const PI: Option<Self>[src]

Loading content...

Required methods

fn parse_binary(s: &str) -> Result<Self, Self::Err>[src]

Parse a binary input without decimals.

Should succeed with or without a leading 0b.

fn parse_octal(s: &str) -> Result<Self, Self::Err>[src]

Parse an octal input without decimals.

Should succeed with or without a leading 0o.

fn parse_decimal(s: &str) -> Result<Self, Self::Err>[src]

Parse a decimal input which may or may not contain a decimal point.

Should succeed with or without a leading 0d.

fn parse_hex(s: &str) -> Result<Self, Self::Err>[src]

Parse an octal input without decimals.

Should succeed with or without a leading 0o.

fn from_f32(f: f32) -> Option<Self>[src]

Instantiate an instance of Self from an f32.

This should be possible with minimal loss for most reasonable types.

fn neg(self) -> Option<Self>[src]

Negate this value.

fn not(self) -> Option<Self>[src]

Bitwise not this value.

fn add(self, other: Self) -> Result<Self, Self::Err>[src]

Add this value and another, returning an error on overflow.

fn sub(self, other: Self) -> Result<Self, Self::Err>[src]

Subtract another value from this, returning an error on underflow.

fn mul(self, other: Self) -> Result<Self, Self::Err>[src]

Multiply this value and another, returning an error on overflow.

fn div(self, other: Self) -> Result<Self, Self::Err>[src]

Divide this value by another, returning an error on divide by zero.

fn trunc_div(self, other: Self) -> Result<Self, Self::Err>[src]

Divide this value by another, flooring the result to the next lowest integer.

fn pow(self, other: Self) -> Result<Self, Self::Err>[src]

Raise this value by another.

fn rem(self, other: Self) -> Result<Self, Self::Err>[src]

Compute the arithmetic remainder of this value and another.

fn shl(self, other: Self) -> Result<Self, Self::Err>[src]

Compute this value left-shifted by other bits.

fn shr(self, other: Self) -> Result<Self, Self::Err>[src]

Compute this value right-shifted by other bits.

fn rotate_left(self, other: Self) -> Result<Self, Self::Err>[src]

Compute this value left-shifted by other bits, wrapping the bits around.

fn rotate_right(self, other: Self) -> Result<Self, Self::Err>[src]

Compute this value right-shifted by other bits, wrapping the bits around.

fn bit_and(self, other: Self) -> Option<Self>[src]

Compute this value bitwise anded with another.

fn bit_or(self, other: Self) -> Option<Self>[src]

Compute this value bitwise or’d with another.

fn bit_xor(self, other: Self) -> Option<Self>[src]

Compute this value bitwise xor’d with another.

fn abs(self) -> Option<Self>[src]

Compute the absolute value of this value.

fn ceil(self) -> Option<Self>[src]

Compute the smallest integer greater than or equal to self.

fn floor(self) -> Option<Self>[src]

Compute the greatest integer less than or equal to self.

fn round(self) -> Option<Self>[src]

Round self to the nearest integer; halfway cases away from 0.0.

fn sin(self) -> Option<Self>[src]

Compute the sine of self.

fn cos(self) -> Option<Self>[src]

Compute the cosine of self.

fn tan(self) -> Option<Self>[src]

Compute the tangent of self.

fn sinh(self) -> Option<Self>[src]

Compute the hyperbolic sine of self.

fn cosh(self) -> Option<Self>[src]

Compute the hyperbolic cosine of self.

fn tanh(self) -> Option<Self>[src]

Compute the hyperbolic tangent of self.

fn asin(self) -> Option<Self>[src]

Compute the arcsine of self.

fn acos(self) -> Option<Self>[src]

Compute the arccosine of self.

fn atan(self) -> Option<Self>[src]

Compute the arctangent of self.

fn asinh(self) -> Option<Self>[src]

Compute the inverse hyperbolic sine of self.

fn acosh(self) -> Option<Self>[src]

Compute the inverse hyperbolic cosine of self.

fn atanh(self) -> Option<Self>[src]

Compute the inverse hyperbolic tangent of self.

fn sqrt(self) -> Option<Self>[src]

Determine the square root of self.

fn cbrt(self) -> Option<Self>[src]

Determine the cube root of self.

fn ln(self) -> Option<Self>[src]

Determine the base-e (natural) logarithm of self.

Loading content...

Provided methods

fn rad(self) -> Option<Self>[src]

Convert self as degrees to radians.

fn deg(self) -> Option<Self>[src]

Convert self as radians to degrees.

fn log(self) -> Option<Self>[src]

Determine the base-10 logarithm of self.

fn lg(self) -> Option<Self>[src]

Determine the base-2 logarithm of self.

fn exp(self) -> Option<Self>[src]

Determine e**self

Loading content...

Implementations on Foreign Types

impl Calcable for f64[src]

type Err = BasicError<f64, ParseFloatError>

impl Calcable for i64[src]

type Err = BasicError<i64, ParseIntError>

impl Calcable for u64[src]

type Err = BasicError<u64, ParseIntError>

Loading content...

Implementors

Loading content...