pub enum CalculatorFloat {
    Float(f64),
    Str(String),
}
Expand description

CalculatorFloat is an enum combining Float and String.

Variants

  • Float - f64 value
  • Str - String instance

Variants§

§

Float(f64)

Floating point value

§

Str(String)

Symbolic expression in String form

Implementations§

source§

impl CalculatorFloat

source

pub const ZERO: CalculatorFloat = _

Constant zero for CalculatorFloat

source

pub const ONE: CalculatorFloat = _

Constant one for CalculatorFloat

source

pub const PI: CalculatorFloat = _

Constant pi for CalculatorFloat

source

pub const E: CalculatorFloat = _

Constant Euler’s number e for CalculatorFloat

source

pub const FRAC_1_SQRT_2: CalculatorFloat = _

Constant 1/sqrt(2) e for CalculatorFloat

source

pub const FRAC_PI_2: CalculatorFloat = _

Constant pi / 2 e for CalculatorFloat

source

pub const FRAC_PI_4: CalculatorFloat = _

Constant pi / 4 e for CalculatorFloat

source

pub const SQRT_2: CalculatorFloat = _

Constant sqrt(2) e for CalculatorFloat

source

pub fn is_float(&self) -> bool

Return True when CalculatorFloat does not contain symbolic expression.

source

pub fn sqrt(&self) -> CalculatorFloat

Return square root of CalculatorFloat.

source

pub fn atan2<T>(&self, other: T) -> CalculatorFloatwhere
T: Into<CalculatorFloat>,

Return atan2 for CalculatorFloat and generic type T.

Arguments
  • other - Any type T for which CalculatorFloat::From trait is implemented
source

pub fn powf<T>(&self, other: T) -> CalculatorFloatwhere
T: Into<CalculatorFloat>,

Return Power for CalculatorFloat and generic type T.

Arguments
  • other - Any type T for which CalculatorFloat::From trait is implemented
source

pub fn exp(&self) -> CalculatorFloat

Return exponential function exp(x) for CalculatorFloat.

source

pub fn sin(&self) -> CalculatorFloat

Return sine function sin(x) for CalculatorFloat.

source

pub fn cos(&self) -> CalculatorFloat

Return cosine function cos(x) for CalculatorFloat.

source

pub fn acos(&self) -> CalculatorFloat

Return arccosine function acos(x) for CalculatorFloat.

source

pub fn abs(&self) -> CalculatorFloat

Return absolute value abs(x) for CalculatorFloat.

source

pub fn signum(&self) -> CalculatorFloat

Return signum value sign(x) for CalculatorFloat.

source

pub fn isclose<T>(&self, other: T) -> boolwhere
T: Into<CalculatorFloat>,

Return True if self value is close to other value.

source

pub fn float(&self) -> Result<&f64, CalculatorError>

Return Some(f64) when CalculatorFloat is a numeric value

source

pub fn recip(&self) -> CalculatorFloat

Return inverse/reciprocal function (1/x) for CalculatorFloat.

Trait Implementations§

source§

impl<'a, T> Add<T> for &'a CalculatorFloatwhere
CalculatorFloat: From<T>,

Implement + (add) for &CalculatorFloat and generic type T.

Arguments

  • other - Any type T for which CalculatorFloat::From trait is implemented
§

type Output = CalculatorFloat

The resulting type after applying the + operator.
source§

fn add(self, other: T) -> CalculatorFloat

Performs the + operation. Read more
source§

impl<T> Add<T> for CalculatorFloatwhere
T: Into<CalculatorFloat>,

Implement + (add) for CalculatorFloat and generic type T.

Arguments

  • other - Any type T for which CalculatorFloat::From trait is implemented
§

type Output = CalculatorFloat

The resulting type after applying the + operator.
source§

fn add(self, other: T) -> Self

Performs the + operation. Read more
source§

impl<T> AddAssign<T> for CalculatorFloatwhere
T: Into<CalculatorFloat>,

Implement += (add) for CalculatorFloat and generic type T.

Arguments

  • other - Any type T for which CalculatorFloat::From trait is implemented
source§

fn add_assign(&mut self, other: T)

Performs the += operation. Read more
source§

impl Clone for CalculatorFloat

source§

fn clone(&self) -> CalculatorFloat

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for CalculatorFloat

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for CalculatorFloat

Implement Default value 0 for CalculatorFloat.

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for CalculatorFloat

source§

fn deserialize<D>(deserializer: D) -> Result<CalculatorFloat, D::Error>where
D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for CalculatorFloat

Implement Display trait for CalculatorFloat.

Allows use of simple text formating

source§

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

Formats the value using the given formatter. Read more
source§

impl<T> Div<T> for CalculatorFloatwhere
T: Into<CalculatorFloat>,

Implement / (divide) for CalculatorFloat and generic type T.

Arguments

  • other - Any type T for which CalculatorFloat::From trait is implemented

Panics

Panics on division by zero. Division by zero is only detected when other is converted to CalculatorFloat::Float

§

type Output = CalculatorFloat

The resulting type after applying the / operator.
source§

fn div(self, other: T) -> Self

Performs the / operation. Read more
source§

impl<T> DivAssign<T> for CalculatorFloatwhere
T: Into<CalculatorFloat>,

Implement /= (divide) for CalculatorFloat and generic type T.

Arguments

  • other - Any type T for which CalculatorFloat::From trait is implemented

Panics

Panics on division by zero. Division by zero is only detected when other is converted to CalculatorFloat::Float

source§

fn div_assign(&mut self, other: T)

Performs the /= operation. Read more
source§

impl<'a> From<&'a CalculatorFloat> for CalculatorFloat

Initialize CalculatorFloat from CalculatorFloat reference &CalculatorFloat.

Returns

  • CalculatorFloat
source§

fn from(item: &'a CalculatorFloat) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a f64> for CalculatorFloat

Initialize CalculatorFloat from f64 reference &.

Returns

  • CalculatorFloat::Float
source§

fn from(item: &'a f64) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a i32> for CalculatorFloat

Initialize CalculatorFloat from i32 reference &.

Returns

  • CalculatorFloat::Float
source§

fn from(item: &'a i32) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a u32> for CalculatorFloat

Initialize CalculatorFloat from usize reference &.

Returns

  • CalculatorFloat::Float
source§

fn from(item: &'a u32) -> Self

Converts to this type from the input type.
source§

impl From<&String> for CalculatorFloat

Initialize CalculatorFloat from string reference &String.

Returns

  • CalculatorFloat::Float
source§

fn from(item: &String) -> Self

Converts to this type from the input type.
source§

impl From<&str> for CalculatorFloat

Initialize CalculatorFloat from str reference &str.

Returns

  • CalculatorFloat::Float
source§

fn from(item: &str) -> Self

Converts to this type from the input type.
source§

impl From<CalculatorFloat> for String

Return CalculatorFloat as String.

Returns

  • String
source§

fn from(value: CalculatorFloat) -> Self

Converts to this type from the input type.
source§

impl From<String> for CalculatorFloat

Initialize CalculatorFloat from string value.

Returns

  • CalculatorFloat::Str
source§

fn from(item: String) -> Self

Converts to this type from the input type.
source§

impl From<f64> for CalculatorFloat

Initialize CalculatorFloat from f64 value.

Returns

  • CalculatorFloat::Float
source§

fn from(item: f64) -> Self

Converts to this type from the input type.
source§

impl From<i32> for CalculatorFloat

Initialize CalculatorFloat from i32 value.

Returns

  • CalculatorFloat::Float
source§

fn from(item: i32) -> Self

Converts to this type from the input type.
source§

impl From<u32> for CalculatorFloat

Initialize CalculatorFloat from usize value.

Returns

  • CalculatorFloat::Float
source§

fn from(item: u32) -> Self

Converts to this type from the input type.
source§

impl FromStr for CalculatorFloat

§

type Err = CalculatorError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

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

impl<T> Mul<T> for &CalculatorFloatwhere
T: Into<CalculatorFloat>,

Implement * (multiply) for CalculatorFloat and generic type T.

Arguments

  • other - Any type T for which CalculatorFloat::From trait is implemented
§

type Output = CalculatorFloat

The resulting type after applying the * operator.
source§

fn mul(self, other: T) -> CalculatorFloat

Performs the * operation. Read more
source§

impl<T> Mul<T> for CalculatorFloatwhere
T: Into<CalculatorFloat>,

Implement * (multiply) for CalculatorFloat and generic type T.

Arguments

  • other - Any type T for which CalculatorFloat::From trait is implemented
§

type Output = CalculatorFloat

The resulting type after applying the * operator.
source§

fn mul(self, other: T) -> Self

Performs the * operation. Read more
source§

impl<T> MulAssign<T> for CalculatorFloatwhere
T: Into<CalculatorFloat>,

Implement *= (multiply) for CalculatorFloat and generic type T.

Arguments

  • other - Any type T for which CalculatorFloat::From trait is implemented
source§

fn mul_assign(&mut self, other: T)

Performs the *= operation. Read more
source§

impl Neg for CalculatorFloat

Implement minus sign for CalculatorFloat.

§

type Output = CalculatorFloat

The resulting type after applying the - operator.
source§

fn neg(self) -> Self

Performs the unary - operation. Read more
source§

impl PartialEq<CalculatorFloat> for CalculatorFloat

source§

fn eq(&self, other: &CalculatorFloat) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for CalculatorFloat

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>where
S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<T> Sub<T> for CalculatorFloatwhere
T: Into<CalculatorFloat>,

Implement - (subtract) for CalculatorFloat and generic type T.

Arguments

  • other - Any type T for which CalculatorFloat::From trait is implemented
§

type Output = CalculatorFloat

The resulting type after applying the - operator.
source§

fn sub(self, other: T) -> Self

Performs the - operation. Read more
source§

impl<T> SubAssign<T> for CalculatorFloatwhere
T: Into<CalculatorFloat>,

Implement -= (subtract) for CalculatorFloat and generic type T.

Arguments

  • other - Any type T for which CalculatorFloat::From trait is implemented
source§

fn sub_assign(&mut self, other: T)

Performs the -= operation. Read more
source§

impl Sum<CalculatorFloat> for CalculatorFloat

Implements summing over an iterator of CalculatorFloat

Arguments

  • iter - Any iterator over CalculatorFloat items
source§

fn sum<I: Iterator<Item = CalculatorFloat>>(iter: I) -> Self

Method which takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl TryFrom<CalculatorFloat> for f64

Try turning CalculatorFloat into f64 float.

Returns

  • f64

Panics

Panics when CalculatorFloat contains symbolic string value

§

type Error = CalculatorError

The type returned in the event of a conversion error.
source§

fn try_from(value: CalculatorFloat) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl StructuralPartialEq for CalculatorFloat

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere
T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere
T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere
T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere
U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere
T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere
T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere
U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere
U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,