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>;
Show 45 methods
fn parse_binary(s: &str) -> Result<Self, <Self as Calcable>::Err>;
fn parse_octal(s: &str) -> Result<Self, <Self as Calcable>::Err>;
fn parse_decimal(s: &str) -> Result<Self, <Self as Calcable>::Err>;
fn parse_hex(s: &str) -> Result<Self, <Self as Calcable>::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 as Calcable>::Err>;
fn sub(self, other: Self) -> Result<Self, <Self as Calcable>::Err>;
fn mul(self, other: Self) -> Result<Self, <Self as Calcable>::Err>;
fn div(self, other: Self) -> Result<Self, <Self as Calcable>::Err>;
fn trunc_div(self, other: Self) -> Result<Self, <Self as Calcable>::Err>;
fn pow(self, other: Self) -> Result<Self, <Self as Calcable>::Err>;
fn rem(self, other: Self) -> Result<Self, <Self as Calcable>::Err>;
fn shl(self, other: Self) -> Result<Self, <Self as Calcable>::Err>;
fn shr(self, other: Self) -> Result<Self, <Self as Calcable>::Err>;
fn rotate_left(self, other: Self) -> Result<Self, <Self as Calcable>::Err>;
fn rotate_right(self, other: Self) -> Result<Self, <Self as Calcable>::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> { ... }
}
Expand description
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.
Required Associated Types
type Err: Error + CalcableError
Required Associated Constants
Required Methods
Parse a binary input without decimals.
Should succeed with or without a leading 0b
.
Parse an octal input without decimals.
Should succeed with or without a leading 0o
.
Parse a decimal input which may or may not contain a decimal point.
Should succeed with or without a leading 0d
.
Parse an octal input without decimals.
Should succeed with or without a leading 0o
.
Instantiate an instance of Self
from an f32
.
This should be possible with minimal loss for most reasonable types.
Add this value and another, returning an error on overflow.
Subtract another value from this, returning an error on underflow.
Multiply this value and another, returning an error on overflow.
Divide this value by another, returning an error on divide by zero.
Divide this value by another, flooring the result to the next lowest integer.
Raise this value by another.
Compute the arithmetic remainder of this value and another.
Compute this value left-shifted by other
bits.
Compute this value right-shifted by other
bits.
fn rotate_left(self, other: Self) -> Result<Self, <Self as Calcable>::Err>
fn rotate_left(self, other: Self) -> Result<Self, <Self as Calcable>::Err>
Compute this value left-shifted by other
bits, wrapping the bits around.
fn rotate_right(self, other: Self) -> Result<Self, <Self as Calcable>::Err>
fn rotate_right(self, other: Self) -> Result<Self, <Self as Calcable>::Err>
Compute this value right-shifted by other
bits, wrapping the bits around.