Enum tc_value::Number

source ·
pub enum Number {
    Bool(Boolean),
    Complex(Complex),
    Float(Float),
    Int(Int),
    UInt(UInt),
}
Expand description

A generic number.

Variants§

§

Bool(Boolean)

§

Complex(Complex)

§

Float(Float)

§

Int(Int)

§

UInt(UInt)

Implementations§

source§

impl Number

source

pub fn is_float(&self) -> bool

Return true if this is floating-point Number, false if this is an integer.

source

pub fn is_int(&self) -> bool

Return true if this is an Int or UInt.

source

pub fn is_real(&self) -> bool

Return false if this is a Complex Number.

Trait Implementations§

source§

impl Add for Number

§

type Output = Number

The resulting type after applying the + operator.
source§

fn add(self, other: Number) -> Number

Performs the + operation. Read more
source§

impl AddAssign for Number

source§

fn add_assign(&mut self, other: Number)

Performs the += operation. Read more
source§

impl AsType<Number> for Value

source§

fn as_type(&self) -> Option<&Number>

Borrow this instance as an instance of T if possible.
source§

fn as_type_mut(&mut self) -> Option<&mut Number>

Borrow this instance mutably as an instance of T if possible.
source§

fn into_type(self) -> Option<Number>

Convert this instance into an instance of T if possible.
source§

impl CastFrom<Number> for Boolean

source§

fn cast_from(number: Number) -> Boolean

Cast an instance of T into an instance of Self.
source§

impl CastFrom<Number> for Complex

source§

fn cast_from(number: Number) -> Complex

Cast an instance of T into an instance of Self.
source§

impl CastFrom<Number> for Float

source§

fn cast_from(number: Number) -> Float

Cast an instance of T into an instance of Self.
source§

impl CastFrom<Number> for Int

source§

fn cast_from(number: Number) -> Int

Cast an instance of T into an instance of Self.
source§

impl CastFrom<Number> for UInt

source§

fn cast_from(number: Number) -> UInt

Cast an instance of T into an instance of Self.
source§

impl Clone for Number

source§

fn clone(&self) -> Number

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 Number

source§

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

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

impl Default for Number

source§

fn default() -> Number

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

impl<'de> Deserialize<'de> for Number

source§

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

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

impl Display for Number

source§

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

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

impl Div for Number

§

type Output = Number

The resulting type after applying the / operator.
source§

fn div(self, other: Number) -> Number

Performs the / operation. Read more
source§

impl DivAssign for Number

source§

fn div_assign(&mut self, other: Number)

Performs the /= operation. Read more
source§

impl FloatInstance for Number

source§

fn is_infinite(&self) -> bool

Return true if this Number is infinite (e.g. f32::INFINITY).
source§

fn is_nan(&self) -> bool

Return true if this is not a valid number (NaN).
source§

impl From<[f32; 2]> for Number

source§

fn from(arr: [f32; 2]) -> Number

Converts to this type from the input type.
source§

impl From<[f64; 2]> for Number

source§

fn from(arr: [f64; 2]) -> Number

Converts to this type from the input type.
source§

impl From<Boolean> for Number

source§

fn from(b: Boolean) -> Number

Converts to this type from the input type.
source§

impl From<Complex<f32>> for Number

source§

fn from(c: Complex<f32>) -> Number

Converts to this type from the input type.
source§

impl From<Complex<f64>> for Number

source§

fn from(c: Complex<f64>) -> Number

Converts to this type from the input type.
source§

impl From<Complex> for Number

source§

fn from(c: Complex) -> Number

Converts to this type from the input type.
source§

impl From<Float> for Number

source§

fn from(f: Float) -> Number

Converts to this type from the input type.
source§

impl From<Int> for Number

source§

fn from(i: Int) -> Number

Converts to this type from the input type.
source§

impl From<Number> for TCString

source§

fn from(n: Number) -> Self

Converts to this type from the input type.
source§

impl From<Number> for Value

source§

fn from(t: Number) -> Self

Converts to this type from the input type.
source§

impl From<UInt> for Number

source§

fn from(u: UInt) -> Number

Converts to this type from the input type.
source§

impl From<bool> for Number

source§

fn from(b: bool) -> Number

Converts to this type from the input type.
source§

impl From<f32> for Number

source§

fn from(f: f32) -> Number

Converts to this type from the input type.
source§

impl From<f64> for Number

source§

fn from(f: f64) -> Number

Converts to this type from the input type.
source§

impl From<i16> for Number

source§

fn from(i: i16) -> Number

Converts to this type from the input type.
source§

impl From<i32> for Number

source§

fn from(i: i32) -> Number

Converts to this type from the input type.
source§

impl From<i64> for Number

source§

fn from(i: i64) -> Number

Converts to this type from the input type.
source§

impl From<i8> for Number

source§

fn from(i: i8) -> Number

Converts to this type from the input type.
source§

impl From<u16> for Number

source§

fn from(u: u16) -> Number

Converts to this type from the input type.
source§

impl From<u32> for Number

source§

fn from(u: u32) -> Number

Converts to this type from the input type.
source§

impl From<u64> for Number

source§

fn from(u: u64) -> Number

Converts to this type from the input type.
source§

impl From<u8> for Number

source§

fn from(u: u8) -> Number

Converts to this type from the input type.
source§

impl FromStr for Number

§

type Err = Error

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

fn from_str(s: &str) -> Result<Number, <Number as FromStr>::Err>

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

impl FromStream for Number

§

type Context = ()

The decoding context of this type, useful in situations where the stream to be decoded may be too large to hold in main memory. Read more
source§

fn from_stream<'life0, 'async_trait, D>( _context: (), decoder: &'life0 mut D ) -> Pin<Box<dyn Future<Output = Result<Number, <D as Decoder>::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, D: 'async_trait + Decoder, Number: 'async_trait,

Parse this value using the given Decoder.
source§

impl GetSize for Number

source§

fn get_heap_size(&self) -> usize

Determines how many bytes this object occupies inside the heap. Read more
source§

fn get_stack_size() -> usize

Determines how may bytes this object occupies inside the stack. Read more
source§

fn get_size(&self) -> usize

Determines the total size of the object. Read more
source§

impl<D> Hash<D> for Number
where D: Digest,

source§

fn hash(self) -> GenericArray<u8, <D as OutputSizeUser>::OutputSize>

Compute the SHA-2 hash of this value
source§

impl Hash for Number

source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'en> IntoStream<'en> for Number

source§

fn into_stream<E>( self, e: E ) -> Result<<E as Encoder<'en>>::Ok, <E as Encoder<'en>>::Error>
where E: Encoder<'en>,

Take ownership of this value and serialize it into the given encoder.
source§

impl Mul for Number

§

type Output = Number

The resulting type after applying the * operator.
source§

fn mul(self, other: Number) -> Number

Performs the * operation. Read more
source§

impl MulAssign for Number

source§

fn mul_assign(&mut self, other: Number)

Performs the *= operation. Read more
source§

impl NumberInstance for Number

§

type Abs = Number

§

type Exp = Number

§

type Log = Number

§

type Round = Number

§

type Class = NumberType

source§

fn class(&self) -> NumberType

Get an impl of NumberClass describing this number.
source§

fn into_type(self, dtype: NumberType) -> Number

Cast this number into the specified NumberClass.
source§

fn abs(self) -> Number

Calculate the absolute value of this number.
source§

fn exp(self) -> <Number as NumberInstance>::Exp

Raise e to the power of this number.
source§

fn ln(self) -> <Number as NumberInstance>::Log

Compute the natural logarithm of this number.
source§

fn log<N>(self, base: N) -> <Number as NumberInstance>::Log
where N: NumberInstance, Float: From<N>,

Compute the logarithm of this number with respect to the given base.
source§

fn pow(self, exp: Number) -> Number

Raise this number to the given exponent. Read more
source§

fn round(self) -> <Number as NumberInstance>::Round

Return this number rounded to the nearest integer.
source§

fn and(self, other: Self) -> Self
where Boolean: CastFrom<Self>,

Return true if self and other are nonzero.
source§

fn not(self) -> Self
where Boolean: CastFrom<Self>,

Return true if this number is zero.
source§

fn or(self, other: Self) -> Self
where Boolean: CastFrom<Self>,

Return true if self or other is nonzero.
source§

fn xor(self, other: Self) -> Self
where Boolean: CastFrom<Self>,

Return true if exactly one of self and other is zero.
source§

impl PartialEq for Number

source§

fn eq(&self, other: &Number) -> 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 PartialOrd for Number

source§

fn partial_cmp(&self, other: &Number) -> Option<Ordering>

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

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

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

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 more
1.0.0 · source§

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

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

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

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

impl Product for Number

source§

fn product<I>(iter: I) -> Number
where I: Iterator<Item = Number>,

Method which takes an iterator and generates Self from the elements by multiplying the items.
source§

impl Rem for Number

§

type Output = Number

The resulting type after applying the % operator.
source§

fn rem(self, other: Number) -> <Number as Rem>::Output

Performs the % operation. Read more
source§

impl RemAssign for Number

source§

fn rem_assign(&mut self, other: Number)

Performs the %= operation. Read more
source§

impl Serialize for Number

source§

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

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

impl Sub for Number

§

type Output = Number

The resulting type after applying the - operator.
source§

fn sub(self, other: Number) -> Number

Performs the - operation. Read more
source§

impl SubAssign for Number

source§

fn sub_assign(&mut self, other: Number)

Performs the -= operation. Read more
source§

impl Sum for Number

source§

fn sum<I>(iter: I) -> Number
where I: Iterator<Item = Number>,

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

impl<'en> ToStream<'en> for Number

source§

fn to_stream<E>( &'en self, e: E ) -> Result<<E as Encoder<'en>>::Ok, <E as Encoder<'en>>::Error>
where E: Encoder<'en>,

Serialize this value into the given encoder.
source§

impl Trigonometry for Number

§

type Out = Number

source§

fn asin(self) -> <Number as Trigonometry>::Out

Arcsine
source§

fn sin(self) -> <Number as Trigonometry>::Out

Sine
source§

fn asinh(self) -> <Number as Trigonometry>::Out

Hyperbolic arcsine
source§

fn sinh(self) -> <Number as Trigonometry>::Out

Hyperbolic sine
source§

fn acos(self) -> <Number as Trigonometry>::Out

Hyperbolic arccosine
source§

fn cos(self) -> <Number as Trigonometry>::Out

Cosine
source§

fn acosh(self) -> <Number as Trigonometry>::Out

Hyperbolic arccosine
source§

fn cosh(self) -> <Number as Trigonometry>::Out

Hyperbolic cosine
source§

fn atan(self) -> <Number as Trigonometry>::Out

Arctangent
source§

fn tan(self) -> <Number as Trigonometry>::Out

Tangent
source§

fn atanh(self) -> <Number as Trigonometry>::Out

Hyperbolic arctangent
source§

fn tanh(self) -> <Number as Trigonometry>::Out

Hyperbolic tangent
source§

impl TryCastFrom<Value> for Number

source§

fn can_cast_from(value: &Value) -> bool

Test if value can be cast into Self.
source§

fn opt_cast_from(value: Value) -> Option<Self>

Returns Some(Self) if the source value can be cast into Self, otherwise None.
source§

fn try_cast_from<Err, OnErr>(value: T, on_err: OnErr) -> Result<Self, Err>
where OnErr: FnOnce(&T) -> Err,

Returns Ok(Self) if the source value can be cast into Self, otherwise calls on_err.
source§

impl TryFrom<Value> for Number

§

type Error = TCError

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

fn try_from(value: Value) -> TCResult<Self>

Performs the conversion.
source§

impl Copy for Number

source§

impl Eq for Number

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<F, T> CastFrom<F> for T
where T: From<F>,

source§

fn cast_from(f: F) -> T

Cast an instance of T into an instance of Self.
source§

impl<T, F> CastInto<F> for T
where F: CastFrom<T>,

source§

fn cast_into(self) -> F

Cast an instance of Self into an instance of T.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

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<F> Match for F

source§

fn matches<T>(&self) -> bool
where T: TryCastFrom<Self>,

Returns true if self can be cast into the target type T.
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where 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 T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

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

impl<F, T> TryCastFrom<F> for T
where T: CastFrom<F>,

source§

fn can_cast_from(_: &F) -> bool

Test if value can be cast into Self.
source§

fn opt_cast_from(f: F) -> Option<T>

Returns Some(Self) if the source value can be cast into Self, otherwise None.
source§

fn try_cast_from<Err, OnErr>(value: T, on_err: OnErr) -> Result<Self, Err>
where OnErr: FnOnce(&T) -> Err,

Returns Ok(Self) if the source value can be cast into Self, otherwise calls on_err.
source§

impl<F, T> TryCastInto<T> for F
where T: TryCastFrom<F>,

source§

fn can_cast_into(&self) -> bool

Test if self can be cast into T.
source§

fn opt_cast_into(self) -> Option<T>

Returns Some(T) if self can be cast into T, otherwise None.
source§

fn try_cast_into<Err, OnErr>(self, on_err: OnErr) -> Result<T, Err>
where OnErr: FnOnce(&Self) -> Err,

Returns Ok(T) if self can be cast into T, otherwise calls on_err.
source§

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

§

type Error = Infallible

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

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

Performs the conversion.
source§

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

§

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

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

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

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

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

source§

impl<T, Rhs> NumAssignOps<Rhs> for T
where T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,

source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,

source§

impl<T> ThreadSafe for T
where T: Send + Sync + 'static,