pub struct Percentage(/* private fields */);
Expand description

Percentage Type

  • Example:
let p1 = Percentage::from(0.1f64);
let p2 = Percentage::from(0.1f32);
let p3 = Percentage::try_from("0.1").unwrap();

assert_eq!(p1 + p2, Percentage::from(0.2));
assert_eq!(p1 + 0.2, Percentage::from(0.3));

Trait Implementations§

source§

impl Add<Decimal> for Percentage

§

type Output = Percentage

The resulting type after applying the + operator.
source§

fn add(self, rhs: Decimal) -> Self::Output

Performs the + operation. Read more
source§

impl Add<Percentage> for Decimal

§

type Output = Percentage

The resulting type after applying the + operator.
source§

fn add(self, rhs: Percentage) -> Self::Output

Performs the + operation. Read more
source§

impl Add<Percentage> for f32

§

type Output = Percentage

The resulting type after applying the + operator.
source§

fn add(self, rhs: Percentage) -> Self::Output

Performs the + operation. Read more
source§

impl Add<Percentage> for f64

§

type Output = Percentage

The resulting type after applying the + operator.
source§

fn add(self, rhs: Percentage) -> Self::Output

Performs the + operation. Read more
source§

impl Add<Percentage> for i16

§

type Output = Percentage

The resulting type after applying the + operator.
source§

fn add(self, rhs: Percentage) -> Self::Output

Performs the + operation. Read more
source§

impl Add<Percentage> for i32

§

type Output = Percentage

The resulting type after applying the + operator.
source§

fn add(self, rhs: Percentage) -> Self::Output

Performs the + operation. Read more
source§

impl Add<Percentage> for i64

§

type Output = Percentage

The resulting type after applying the + operator.
source§

fn add(self, rhs: Percentage) -> Self::Output

Performs the + operation. Read more
source§

impl Add<Percentage> for i8

§

type Output = Percentage

The resulting type after applying the + operator.
source§

fn add(self, rhs: Percentage) -> Self::Output

Performs the + operation. Read more
source§

impl Add<Percentage> for isize

§

type Output = Percentage

The resulting type after applying the + operator.
source§

fn add(self, rhs: Percentage) -> Self::Output

Performs the + operation. Read more
source§

impl Add<Percentage> for u16

§

type Output = Percentage

The resulting type after applying the + operator.
source§

fn add(self, rhs: Percentage) -> Self::Output

Performs the + operation. Read more
source§

impl Add<Percentage> for u32

§

type Output = Percentage

The resulting type after applying the + operator.
source§

fn add(self, rhs: Percentage) -> Self::Output

Performs the + operation. Read more
source§

impl Add<Percentage> for u64

§

type Output = Percentage

The resulting type after applying the + operator.
source§

fn add(self, rhs: Percentage) -> Self::Output

Performs the + operation. Read more
source§

impl Add<Percentage> for u8

§

type Output = Percentage

The resulting type after applying the + operator.
source§

fn add(self, rhs: Percentage) -> Self::Output

Performs the + operation. Read more
source§

impl Add<Percentage> for usize

§

type Output = Percentage

The resulting type after applying the + operator.
source§

fn add(self, rhs: Percentage) -> Self::Output

Performs the + operation. Read more
source§

impl Add<f32> for Percentage

§

type Output = Percentage

The resulting type after applying the + operator.
source§

fn add(self, rhs: f32) -> Self::Output

Performs the + operation. Read more
source§

impl Add<f64> for Percentage

§

type Output = Percentage

The resulting type after applying the + operator.
source§

fn add(self, rhs: f64) -> Self::Output

Performs the + operation. Read more
source§

impl Add<i16> for Percentage

§

type Output = Percentage

The resulting type after applying the + operator.
source§

fn add(self, rhs: i16) -> Self::Output

Performs the + operation. Read more
source§

impl Add<i32> for Percentage

§

type Output = Percentage

The resulting type after applying the + operator.
source§

fn add(self, rhs: i32) -> Self::Output

Performs the + operation. Read more
source§

impl Add<i64> for Percentage

§

type Output = Percentage

The resulting type after applying the + operator.
source§

fn add(self, rhs: i64) -> Self::Output

Performs the + operation. Read more
source§

impl Add<i8> for Percentage

§

type Output = Percentage

The resulting type after applying the + operator.
source§

fn add(self, rhs: i8) -> Self::Output

Performs the + operation. Read more
source§

impl Add<isize> for Percentage

§

type Output = Percentage

The resulting type after applying the + operator.
source§

fn add(self, rhs: isize) -> Self::Output

Performs the + operation. Read more
source§

impl Add<u16> for Percentage

§

type Output = Percentage

The resulting type after applying the + operator.
source§

fn add(self, rhs: u16) -> Self::Output

Performs the + operation. Read more
source§

impl Add<u32> for Percentage

§

type Output = Percentage

The resulting type after applying the + operator.
source§

fn add(self, rhs: u32) -> Self::Output

Performs the + operation. Read more
source§

impl Add<u64> for Percentage

§

type Output = Percentage

The resulting type after applying the + operator.
source§

fn add(self, rhs: u64) -> Self::Output

Performs the + operation. Read more
source§

impl Add<u8> for Percentage

§

type Output = Percentage

The resulting type after applying the + operator.
source§

fn add(self, rhs: u8) -> Self::Output

Performs the + operation. Read more
source§

impl Add<usize> for Percentage

§

type Output = Percentage

The resulting type after applying the + operator.
source§

fn add(self, rhs: usize) -> Self::Output

Performs the + operation. Read more
source§

impl Add for Percentage

§

type Output = Percentage

The resulting type after applying the + operator.
source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
source§

impl Clone for Percentage

source§

fn clone(&self) -> Percentage

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 Percentage

source§

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

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

impl<'de> Deserialize<'de> for Percentage

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

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

impl Display for Percentage

source§

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

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

impl From<Decimal> for Percentage

source§

fn from(p: Decimal) -> Self

Converts to this type from the input type.
source§

impl From<f32> for Percentage

source§

fn from(p: f32) -> Self

Converts to this type from the input type.
source§

impl From<f64> for Percentage

source§

fn from(p: f64) -> Self

Converts to this type from the input type.
source§

impl FromStr for Percentage

§

type Err = Error

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

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

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

impl<'a, 'b> Mul<&'a Percentage> for &'b Percentage

§

type Output = Percentage

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &'a Percentage) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<Decimal> for Percentage

§

type Output = Decimal

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Decimal) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<Percentage> for Decimal

§

type Output = Decimal

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Percentage) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<Percentage> for f32

§

type Output = f32

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Percentage) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<Percentage> for f64

§

type Output = f64

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Percentage) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<Percentage> for i16

§

type Output = i16

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Percentage) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<Percentage> for i32

§

type Output = i32

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Percentage) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<Percentage> for i64

§

type Output = i64

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Percentage) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<Percentage> for i8

§

type Output = i8

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Percentage) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<Percentage> for isize

§

type Output = isize

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Percentage) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<Percentage> for u16

§

type Output = u16

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Percentage) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<Percentage> for u32

§

type Output = u32

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Percentage) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<Percentage> for u64

§

type Output = u64

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Percentage) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<Percentage> for u8

§

type Output = u8

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Percentage) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<Percentage> for usize

§

type Output = usize

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Percentage) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<f32> for Percentage

§

type Output = f32

The resulting type after applying the * operator.
source§

fn mul(self, rhs: f32) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<f64> for Percentage

§

type Output = f64

The resulting type after applying the * operator.
source§

fn mul(self, rhs: f64) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<i16> for Percentage

§

type Output = i16

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i16) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<i32> for Percentage

§

type Output = i32

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i32) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<i64> for Percentage

§

type Output = i64

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i64) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<i8> for Percentage

§

type Output = i8

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i8) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<isize> for Percentage

§

type Output = isize

The resulting type after applying the * operator.
source§

fn mul(self, rhs: isize) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<u16> for Percentage

§

type Output = u16

The resulting type after applying the * operator.
source§

fn mul(self, rhs: u16) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<u32> for Percentage

§

type Output = u32

The resulting type after applying the * operator.
source§

fn mul(self, rhs: u32) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<u64> for Percentage

§

type Output = u64

The resulting type after applying the * operator.
source§

fn mul(self, rhs: u64) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<u8> for Percentage

§

type Output = u8

The resulting type after applying the * operator.
source§

fn mul(self, rhs: u8) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<usize> for Percentage

§

type Output = usize

The resulting type after applying the * operator.
source§

fn mul(self, rhs: usize) -> Self::Output

Performs the * operation. Read more
source§

impl Mul for Percentage

§

type Output = Percentage

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
source§

impl Ord for Percentage

source§

fn cmp(&self, other: &Percentage) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for Percentage

source§

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

source§

fn partial_cmp(&self, other: &Percentage) -> 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 Serialize for Percentage

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 Sub<Percentage> for f32

§

type Output = Percentage

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Percentage) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<Percentage> for f64

§

type Output = Percentage

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Percentage) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<Percentage> for i16

§

type Output = Percentage

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Percentage) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<Percentage> for i32

§

type Output = Percentage

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Percentage) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<Percentage> for i64

§

type Output = Percentage

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Percentage) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<Percentage> for i8

§

type Output = Percentage

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Percentage) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<Percentage> for isize

§

type Output = Percentage

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Percentage) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<Percentage> for u16

§

type Output = Percentage

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Percentage) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<Percentage> for u32

§

type Output = Percentage

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Percentage) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<Percentage> for u64

§

type Output = Percentage

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Percentage) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<Percentage> for u8

§

type Output = Percentage

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Percentage) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<Percentage> for usize

§

type Output = Percentage

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Percentage) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<f32> for Percentage

§

type Output = Percentage

The resulting type after applying the - operator.
source§

fn sub(self, rhs: f32) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<f64> for Percentage

§

type Output = Percentage

The resulting type after applying the - operator.
source§

fn sub(self, rhs: f64) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<i16> for Percentage

§

type Output = Percentage

The resulting type after applying the - operator.
source§

fn sub(self, rhs: i16) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<i32> for Percentage

§

type Output = Percentage

The resulting type after applying the - operator.
source§

fn sub(self, rhs: i32) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<i64> for Percentage

§

type Output = Percentage

The resulting type after applying the - operator.
source§

fn sub(self, rhs: i64) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<i8> for Percentage

§

type Output = Percentage

The resulting type after applying the - operator.
source§

fn sub(self, rhs: i8) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<isize> for Percentage

§

type Output = Percentage

The resulting type after applying the - operator.
source§

fn sub(self, rhs: isize) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<u16> for Percentage

§

type Output = Percentage

The resulting type after applying the - operator.
source§

fn sub(self, rhs: u16) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<u32> for Percentage

§

type Output = Percentage

The resulting type after applying the - operator.
source§

fn sub(self, rhs: u32) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<u64> for Percentage

§

type Output = Percentage

The resulting type after applying the - operator.
source§

fn sub(self, rhs: u64) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<u8> for Percentage

§

type Output = Percentage

The resulting type after applying the - operator.
source§

fn sub(self, rhs: u8) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<usize> for Percentage

§

type Output = Percentage

The resulting type after applying the - operator.
source§

fn sub(self, rhs: usize) -> Self::Output

Performs the - operation. Read more
source§

impl Sub for Percentage

§

type Output = Percentage

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
source§

impl TryFrom<&str> for Percentage

§

type Error = Error

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

fn try_from(p: &str) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Copy for Percentage

source§

impl Eq for Percentage

source§

impl StructuralEq for Percentage

source§

impl StructuralPartialEq for Percentage

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<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<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<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.
source§

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