Struct readable::Percent

source ·
pub struct Percent(_, _);
Expand description

Human readable percentage.

Percent::from input can be:

The default Percent::from implementation will print 2 decimal numbers.

Anything lower than 0.01 is rounded down to 0.00.

This can be changed by using different functions when initially creating the Percent, or converting an existing Percent, for example:

let f0 = Percent::new_0(3.0);
let f2 = Percent::from(3.0);
let f3 = Percent::new_3(3.0);
let f4 = Percent::new_4(3.0);

assert!(f0 == "3%");
assert!(f2 == "3.00%");
assert!(f3 == "3.000%");
assert!(f4 == "3.0000%");

Cloning

Clone may be expensive:

// Probably cheap (stack allocated string).
let a = Percent::from(100.0);
let b = a.clone();

// Probably expensive (heap allocated string).
let a = Percent::from(f64::MAX);
let b = a.clone();

The actual string used internally is not a String, but a CompactString so that any string 24 bytes (12 bytes on 32-bit) or less are stack allocated instead of heap allocated.

The documentation will still refer to the inner string as a String. Anything returned will also be a String.

Float Errors

To disable checks for these, (you are sure you don’t have NaN’s), enable the ignore_nan_inf feature flag.

Math

These operators are overloaded. They will always output a new Self:

  • Add +
  • Sub -
  • Div /
  • Mul *
  • Rem %

They can either be:

  • Combined with another Self: Percent::from(1.0) + Percent::from(1.0)
  • Or with the inner number itself: Percent::from(1.0) + 1.0

They also have the same panic!() behavior on overflow as the normal ones, because internally, it is just calling .inner() $OPERATOR $NUMBER.

assert!(Percent::from(10.0) + 10.0 == Percent::from(20.0));
assert!(Percent::from(10.0) - 10.0 == Percent::from(0.0));
assert!(Percent::from(10.0) / 10.0 == Percent::from(1.0));
assert!(Percent::from(10.0) * 10.0 == Percent::from(100.0));
assert!(Percent::from(10.0) % 10.0 == Percent::from(0.0));

Overflow example (floats don’t panic in this case):

let n = Percent::from(f64::MAX) + f64::MAX;
assert!(n.inner().is_infinite());

Examples

assert!(Percent::zero()    == "0.00%");
assert!(Percent::unknown() == "?.??%");

assert!(Percent::from(0.001)   == "0.00%");
assert!(Percent::from(0.1)     == "0.10%");
assert!(Percent::from(1.0)     == "1.00%");
assert!(Percent::from(100.0)   == "100.00%");
assert!(Percent::from(1_000.0) == "1,000.00%");

assert!(Percent::from(1_u32)      == "1.00%");
assert!(Percent::from(1_000_u32)  == "1,000.00%");
assert!(Percent::from(10_000_u32) == "10,000.00%");

assert!(Percent::from(-1_i32)      == "-1.00%");
assert!(Percent::from(-1_000_i32)  == "-1,000.00%");
assert!(Percent::from(-10_000_i32) == "-10,000.00%");

Implementations§

source§

impl Percent

source

pub fn as_str(&self) -> &str

Return a borrowed str without consuming Self.

source

pub fn as_bytes(&self) -> &[u8]

Returns the valid byte slice of the inner String

These bytes can always safely be used for std::str::from_utf8_unchecked.

source

pub fn to_vec(&self) -> Vec<u8>

Return the bytes of the inner String as a Vec

source

pub fn into_vec(self) -> Vec<u8>

Return the bytes of the inner String as a Vec, consuming Self

source

pub const fn inner(&self) -> f64

Returns the inner number.

source

pub fn into_string(self) -> String

Consumes Self, returning the inner String.

source

pub fn into_raw(self) -> (f64, String)

Consumes Self, returning the inner parts.

source

pub fn head(&self, len: usize) -> &str

Return the first len bytes of this str.

This will return the full str if the len is longer than the actual inner str.

Since all readable types happen to only contain ASCII characters, all char’s are equal to 1 byte.

let date = Date::from_str("2021-12-11").unwrap();

assert!(date.head(5) == "2021-");
source

pub fn head_dot(&self, len: usize) -> String

Same as Self::head but returns a String ending with ...

This will return the full string without ... if the len is longer than the actual inner str.

let date = Date::from_str("2021-12-11").unwrap();

assert!(date.head_dot(4) == "2021...");
source

pub fn tail(&self, len: usize) -> &str

Return the last len bytes of this str.

This will return the full str if the len is longer than the actual inner str.

Since all readable types happen to only contain ASCII characters, all char’s are equal to 1 byte.

let date = Date::from_str("2021-12-11").unwrap();

assert!(date.tail(5) == "12-11");
source

pub fn tail_dot(&self, len: usize) -> String

Same as Self::tail but returns a String starting with ...

This will return the full string without ... if the len is longer than the actual inner str.

let date = Date::from_str("2021-12-11").unwrap();

assert!(date.tail_dot(5) == "...12-11");
source

pub fn head_tail(&self, head: usize, tail: usize) -> String

Return the first head bytes and last tail bytes of this string separated with ....

Since all readable types happen to only contain ASCII characters, all char’s are equal to 1 byte.

let date = Date::from_str("2021-12-11").unwrap();

assert!(date.head_tail(3, 2) == "202...11");
assert!(date.head_tail(3, 3) == "202...-11");
assert!(date.head_tail(3, 5) == "202...12-11");
source

pub fn len(&self) -> usize

The length of the inner String

source

pub fn is_empty(&self) -> bool

If the inner String is empty or not

source

pub fn unknown() -> Self

Returns a Self with the f64 value of f64::NAN.

The String is set to ?.??%.

source

pub fn nan() -> Self

Returns a Self with the f64 value of f64::NAN.

The String is set to NaN.

source

pub fn inf() -> Self

Returns a Self with the f64 value of f64::INFINITY.

The String is set to .

source

pub const fn zero() -> Self

Returns a Percent with the f64 value of 0.0.

The String is set to 0.00%.

source

pub const fn const_1() -> Self

Returns a Percent with the f64 value of 1.0.

The String is set to 1.00%.

source

pub const fn const_2() -> Self

Returns a Percent with the f64 value of 2.0.

The String is set to 2.00%.

source

pub const fn const_3() -> Self

Returns a Percent with the f64 value of 3.0.

The String is set to 3.00%.

source

pub const fn const_4() -> Self

Returns a Percent with the f64 value of 4.0.

The String is set to 4.00%.

source

pub const fn const_5() -> Self

Returns a Percent with the f64 value of 5.0.

The String is set to 5.00%.

source

pub const fn const_6() -> Self

Returns a Percent with the f64 value of 6.0.

The String is set to 6.00%.

source

pub const fn const_7() -> Self

Returns a Percent with the f64 value of 7.0.

The String is set to 7.00%.

source

pub const fn const_8() -> Self

Returns a Percent with the f64 value of 8.0.

The String is set to 8.00%.

source

pub const fn const_9() -> Self

Returns a Percent with the f64 value of 9.0.

The String is set to 9.00%.

source

pub const fn const_10() -> Self

Returns a Percent with the f64 value of 10.0.

The String is set to 10.00%.

source

pub const fn const_11() -> Self

Returns a Percent with the f64 value of 11.0.

The String is set to 11.00%.

source

pub const fn const_12() -> Self

Returns a Percent with the f64 value of 12.0.

The String is set to 12.00%.

source

pub const fn const_13() -> Self

Returns a Percent with the f64 value of 13.0.

The String is set to 13.00%.

source

pub const fn const_14() -> Self

Returns a Percent with the f64 value of 14.0.

The String is set to 14.00%.

source

pub const fn const_15() -> Self

Returns a Percent with the f64 value of 15.0.

The String is set to 15.00%.

source

pub const fn const_16() -> Self

Returns a Percent with the f64 value of 16.0.

The String is set to 16.00%.

source

pub const fn const_17() -> Self

Returns a Percent with the f64 value of 17.0.

The String is set to 17.00%.

source

pub const fn const_18() -> Self

Returns a Percent with the f64 value of 18.0.

The String is set to 18.00%.

source

pub const fn const_19() -> Self

Returns a Percent with the f64 value of 19.0.

The String is set to 19.00%.

source

pub const fn const_20() -> Self

Returns a Percent with the f64 value of 20.0.

The String is set to 20.00%.

source

pub const fn const_21() -> Self

Returns a Percent with the f64 value of 21.0.

The String is set to 21.00%.

source

pub const fn const_22() -> Self

Returns a Percent with the f64 value of 22.0.

The String is set to 22.00%.

source

pub const fn const_23() -> Self

Returns a Percent with the f64 value of 23.0.

The String is set to 23.00%.

source

pub const fn const_24() -> Self

Returns a Percent with the f64 value of 24.0.

The String is set to 24.00%.

source

pub const fn const_25() -> Self

Returns a Percent with the f64 value of 25.0.

The String is set to 25.00%.

source

pub const fn const_26() -> Self

Returns a Percent with the f64 value of 26.0.

The String is set to 26.00%.

source

pub const fn const_27() -> Self

Returns a Percent with the f64 value of 27.0.

The String is set to 27.00%.

source

pub const fn const_28() -> Self

Returns a Percent with the f64 value of 28.0.

The String is set to 28.00%.

source

pub const fn const_29() -> Self

Returns a Percent with the f64 value of 29.0.

The String is set to 29.00%.

source

pub const fn const_30() -> Self

Returns a Percent with the f64 value of 30.0.

The String is set to 30.00%.

source

pub const fn const_31() -> Self

Returns a Percent with the f64 value of 31.0.

The String is set to 31.00%.

source

pub const fn const_32() -> Self

Returns a Percent with the f64 value of 32.0.

The String is set to 32.00%.

source

pub const fn const_33() -> Self

Returns a Percent with the f64 value of 33.0.

The String is set to 33.00%.

source

pub const fn const_34() -> Self

Returns a Percent with the f64 value of 34.0.

The String is set to 34.00%.

source

pub const fn const_35() -> Self

Returns a Percent with the f64 value of 35.0.

The String is set to 35.00%.

source

pub const fn const_36() -> Self

Returns a Percent with the f64 value of 36.0.

The String is set to 36.00%.

source

pub const fn const_37() -> Self

Returns a Percent with the f64 value of 37.0.

The String is set to 37.00%.

source

pub const fn const_38() -> Self

Returns a Percent with the f64 value of 38.0.

The String is set to 38.00%.

source

pub const fn const_39() -> Self

Returns a Percent with the f64 value of 39.0.

The String is set to 39.00%.

source

pub const fn const_40() -> Self

Returns a Percent with the f64 value of 40.0.

The String is set to 40.00%.

source

pub const fn const_41() -> Self

Returns a Percent with the f64 value of 41.0.

The String is set to 41.00%.

source

pub const fn const_42() -> Self

Returns a Percent with the f64 value of 42.0.

The String is set to 42.00%.

source

pub const fn const_43() -> Self

Returns a Percent with the f64 value of 43.0.

The String is set to 43.00%.

source

pub const fn const_44() -> Self

Returns a Percent with the f64 value of 44.0.

The String is set to 44.00%.

source

pub const fn const_45() -> Self

Returns a Percent with the f64 value of 45.0.

The String is set to 45.00%.

source

pub const fn const_46() -> Self

Returns a Percent with the f64 value of 46.0.

The String is set to 46.00%.

source

pub const fn const_47() -> Self

Returns a Percent with the f64 value of 47.0.

The String is set to 47.00%.

source

pub const fn const_48() -> Self

Returns a Percent with the f64 value of 48.0.

The String is set to 48.00%.

source

pub const fn const_49() -> Self

Returns a Percent with the f64 value of 49.0.

The String is set to 49.00%.

source

pub const fn const_50() -> Self

Returns a Percent with the f64 value of 50.0.

The String is set to 50.00%.

source

pub const fn const_51() -> Self

Returns a Percent with the f64 value of 51.0.

The String is set to 51.00%.

source

pub const fn const_52() -> Self

Returns a Percent with the f64 value of 52.0.

The String is set to 52.00%.

source

pub const fn const_53() -> Self

Returns a Percent with the f64 value of 53.0.

The String is set to 53.00%.

source

pub const fn const_54() -> Self

Returns a Percent with the f64 value of 54.0.

The String is set to 54.00%.

source

pub const fn const_55() -> Self

Returns a Percent with the f64 value of 55.0.

The String is set to 55.00%.

source

pub const fn const_56() -> Self

Returns a Percent with the f64 value of 56.0.

The String is set to 56.00%.

source

pub const fn const_57() -> Self

Returns a Percent with the f64 value of 57.0.

The String is set to 57.00%.

source

pub const fn const_58() -> Self

Returns a Percent with the f64 value of 58.0.

The String is set to 58.00%.

source

pub const fn const_59() -> Self

Returns a Percent with the f64 value of 59.0.

The String is set to 59.00%.

source

pub const fn const_60() -> Self

Returns a Percent with the f64 value of 60.0.

The String is set to 60.00%.

source

pub const fn const_61() -> Self

Returns a Percent with the f64 value of 61.0.

The String is set to 61.00%.

source

pub const fn const_62() -> Self

Returns a Percent with the f64 value of 62.0.

The String is set to 62.00%.

source

pub const fn const_63() -> Self

Returns a Percent with the f64 value of 63.0.

The String is set to 63.00%.

source

pub const fn const_64() -> Self

Returns a Percent with the f64 value of 64.0.

The String is set to 64.00%.

source

pub const fn const_65() -> Self

Returns a Percent with the f64 value of 65.0.

The String is set to 65.00%.

source

pub const fn const_66() -> Self

Returns a Percent with the f64 value of 66.0.

The String is set to 66.00%.

source

pub const fn const_67() -> Self

Returns a Percent with the f64 value of 67.0.

The String is set to 67.00%.

source

pub const fn const_68() -> Self

Returns a Percent with the f64 value of 68.0.

The String is set to 68.00%.

source

pub const fn const_69() -> Self

Returns a Percent with the f64 value of 69.0.

The String is set to 69.00%.

source

pub const fn const_70() -> Self

Returns a Percent with the f64 value of 70.0.

The String is set to 70.00%.

source

pub const fn const_71() -> Self

Returns a Percent with the f64 value of 71.0.

The String is set to 71.00%.

source

pub const fn const_72() -> Self

Returns a Percent with the f64 value of 72.0.

The String is set to 72.00%.

source

pub const fn const_73() -> Self

Returns a Percent with the f64 value of 73.0.

The String is set to 73.00%.

source

pub const fn const_74() -> Self

Returns a Percent with the f64 value of 74.0.

The String is set to 74.00%.

source

pub const fn const_75() -> Self

Returns a Percent with the f64 value of 75.0.

The String is set to 75.00%.

source

pub const fn const_76() -> Self

Returns a Percent with the f64 value of 76.0.

The String is set to 76.00%.

source

pub const fn const_77() -> Self

Returns a Percent with the f64 value of 77.0.

The String is set to 77.00%.

source

pub const fn const_78() -> Self

Returns a Percent with the f64 value of 78.0.

The String is set to 78.00%.

source

pub const fn const_79() -> Self

Returns a Percent with the f64 value of 79.0.

The String is set to 79.00%.

source

pub const fn const_80() -> Self

Returns a Percent with the f64 value of 80.0.

The String is set to 80.00%.

source

pub const fn const_81() -> Self

Returns a Percent with the f64 value of 81.0.

The String is set to 81.00%.

source

pub const fn const_82() -> Self

Returns a Percent with the f64 value of 82.0.

The String is set to 82.00%.

source

pub const fn const_83() -> Self

Returns a Percent with the f64 value of 83.0.

The String is set to 83.00%.

source

pub const fn const_84() -> Self

Returns a Percent with the f64 value of 84.0.

The String is set to 84.00%.

source

pub const fn const_85() -> Self

Returns a Percent with the f64 value of 85.0.

The String is set to 85.00%.

source

pub const fn const_86() -> Self

Returns a Percent with the f64 value of 86.0.

The String is set to 86.00%.

source

pub const fn const_87() -> Self

Returns a Percent with the f64 value of 87.0.

The String is set to 87.00%.

source

pub const fn const_88() -> Self

Returns a Percent with the f64 value of 88.0.

The String is set to 88.00%.

source

pub const fn const_89() -> Self

Returns a Percent with the f64 value of 89.0.

The String is set to 89.00%.

source

pub const fn const_90() -> Self

Returns a Percent with the f64 value of 90.0.

The String is set to 90.00%.

source

pub const fn const_91() -> Self

Returns a Percent with the f64 value of 91.0.

The String is set to 91.00%.

source

pub const fn const_92() -> Self

Returns a Percent with the f64 value of 92.0.

The String is set to 92.00%.

source

pub const fn const_93() -> Self

Returns a Percent with the f64 value of 93.0.

The String is set to 93.00%.

source

pub const fn const_94() -> Self

Returns a Percent with the f64 value of 94.0.

The String is set to 94.00%.

source

pub const fn const_95() -> Self

Returns a Percent with the f64 value of 95.0.

The String is set to 95.00%.

source

pub const fn const_96() -> Self

Returns a Percent with the f64 value of 96.0.

The String is set to 96.00%.

source

pub const fn const_97() -> Self

Returns a Percent with the f64 value of 97.0.

The String is set to 97.00%.

source

pub const fn const_98() -> Self

Returns a Percent with the f64 value of 98.0.

The String is set to 98.00%.

source

pub const fn const_99() -> Self

Returns a Percent with the f64 value of 99.0.

The String is set to 99.00%.

source

pub const fn const_100() -> Self

Returns a Percent with the f64 value of 100.0.

The String is set to 100.00%.

source

pub fn new_0(f: f64) -> Self

Same as Self::from but with no floating point on the inner String.

The inner f64 stays the same as the input.

This does not round up or down, it completely ignores the floating point.

Examples
InputString Output
0.00%
50.12350%
100.1100%
source

pub fn new_1(f: f64) -> Self

Same as Percent::from but with 1 floating point.

source

pub fn new_3(f: f64) -> Self

Same as Percent::from but with 3 floating point.

source

pub fn new_4(f: f64) -> Self

Same as Percent::from but with 4 floating point.

source

pub fn new_5(f: f64) -> Self

Same as Percent::from but with 5 floating point.

source

pub fn new_6(f: f64) -> Self

Same as Percent::from but with 6 floating point.

source

pub fn new_7(f: f64) -> Self

Same as Percent::from but with 7 floating point.

source

pub fn new_8(f: f64) -> Self

Same as Percent::from but with 8 floating point.

source

pub fn new_9(f: f64) -> Self

Same as Percent::from but with 9 floating point.

source

pub fn new_10(f: f64) -> Self

Same as Percent::from but with 10 floating point.

source

pub fn new_11(f: f64) -> Self

Same as Percent::from but with 11 floating point.

source

pub fn new_12(f: f64) -> Self

Same as Percent::from but with 12 floating point.

source

pub fn new_13(f: f64) -> Self

Same as Percent::from but with 13 floating point.

source

pub fn new_14(f: f64) -> Self

Same as Percent::from but with 14 floating point.

Trait Implementations§

source§

impl Add<&Percent> for Percent

§

type Output = Percent

The resulting type after applying the + operator.
source§

fn add(self, other: &Percent) -> Self

Performs the + operation. Read more
source§

impl Add<&Percent> for f64

§

type Output = f64

The resulting type after applying the + operator.
source§

fn add(self, other: &Percent) -> Self

Performs the + operation. Read more
source§

impl Add<&f64> for Percent

§

type Output = Percent

The resulting type after applying the + operator.
source§

fn add(self, other: &f64) -> Self

Performs the + operation. Read more
source§

impl Add<Percent> for Percent

§

type Output = Percent

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl Add<Percent> for f64

§

type Output = f64

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl Add<f64> for Percent

§

type Output = Percent

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<'__de> BorrowDecode<'__de> for Percent

source§

fn borrow_decode<__D: BorrowDecoder<'__de>>( decoder: &mut __D ) -> Result<Self, DecodeError>

Attempt to decode this type with the given BorrowDecode.
source§

impl Clone for Percent

source§

fn clone(&self) -> Percent

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 Percent

source§

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

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

impl Decode for Percent

source§

fn decode<__D: Decoder>(decoder: &mut __D) -> Result<Self, DecodeError>

Attempt to decode this type with the given Decode.
source§

impl Default for Percent

source§

fn default() -> Self

Calls Self::zero

source§

impl<'de> Deserialize<'de> for Percent

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 Percent

source§

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

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

impl Div<&Percent> for Percent

§

type Output = Percent

The resulting type after applying the / operator.
source§

fn div(self, other: &Percent) -> Self

Performs the / operation. Read more
source§

impl Div<&Percent> for f64

§

type Output = f64

The resulting type after applying the / operator.
source§

fn div(self, other: &Percent) -> Self

Performs the / operation. Read more
source§

impl Div<&f64> for Percent

§

type Output = Percent

The resulting type after applying the / operator.
source§

fn div(self, other: &f64) -> Self

Performs the / operation. Read more
source§

impl Div<Percent> for Percent

§

type Output = Percent

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl Div<Percent> for f64

§

type Output = f64

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl Div<f64> for Percent

§

type Output = Percent

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl Encode for Percent

source§

fn encode<__E: Encoder>(&self, encoder: &mut __E) -> Result<(), EncodeError>

Encode a given type.
source§

impl From<f32> for Percent

source§

fn from(number: f32) -> Self

Converts to this type from the input type.
source§

impl From<f64> for Percent

source§

fn from(f: f64) -> Self

Converts to this type from the input type.
source§

impl From<i16> for Percent

source§

fn from(number: i16) -> Self

Converts to this type from the input type.
source§

impl From<i32> for Percent

source§

fn from(number: i32) -> Self

Converts to this type from the input type.
source§

impl From<i8> for Percent

source§

fn from(number: i8) -> Self

Converts to this type from the input type.
source§

impl From<u16> for Percent

source§

fn from(number: u16) -> Self

Converts to this type from the input type.
source§

impl From<u32> for Percent

source§

fn from(number: u32) -> Self

Converts to this type from the input type.
source§

impl From<u8> for Percent

source§

fn from(number: u8) -> Self

Converts to this type from the input type.
source§

impl Mul<&Percent> for Percent

§

type Output = Percent

The resulting type after applying the * operator.
source§

fn mul(self, other: &Percent) -> Self

Performs the * operation. Read more
source§

impl Mul<&Percent> for f64

§

type Output = f64

The resulting type after applying the * operator.
source§

fn mul(self, other: &Percent) -> Self

Performs the * operation. Read more
source§

impl Mul<&f64> for Percent

§

type Output = Percent

The resulting type after applying the * operator.
source§

fn mul(self, other: &f64) -> Self

Performs the * operation. Read more
source§

impl Mul<Percent> for Percent

§

type Output = Percent

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Mul<Percent> for f64

§

type Output = f64

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Mul<f64> for Percent

§

type Output = Percent

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl PartialEq<&Percent> for f64

source§

fn eq(&self, other: &&Percent) -> 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 PartialEq<&Percent> for str

source§

fn eq(&self, other: &&Percent) -> 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 PartialEq<&str> for Percent

source§

fn eq(&self, other: &&str) -> 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 PartialEq<Percent> for Percent

source§

fn eq(&self, other: &Percent) -> 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 PartialEq<Percent> for f64

source§

fn eq(&self, other: &Percent) -> 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 PartialEq<Percent> for str

source§

fn eq(&self, other: &Percent) -> 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 PartialEq<f64> for &Percent

source§

fn eq(&self, other: &f64) -> 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 PartialEq<f64> for Percent

source§

fn eq(&self, other: &f64) -> 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 PartialEq<str> for Percent

source§

fn eq(&self, other: &str) -> 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<&Percent> for f64

source§

fn partial_cmp(&self, other: &&Percent) -> 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 PartialOrd<&Percent> for str

source§

fn partial_cmp(&self, other: &&Percent) -> 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 PartialOrd<&str> for Percent

source§

fn partial_cmp(&self, other: &&str) -> 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 PartialOrd<Percent> for Percent

source§

fn partial_cmp(&self, other: &Percent) -> 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 PartialOrd<Percent> for f64

source§

fn partial_cmp(&self, other: &Percent) -> 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 PartialOrd<Percent> for str

source§

fn partial_cmp(&self, other: &Percent) -> 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 PartialOrd<f64> for &Percent

source§

fn partial_cmp(&self, other: &f64) -> 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 PartialOrd<f64> for Percent

source§

fn partial_cmp(&self, other: &f64) -> 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 PartialOrd<str> for Percent

source§

fn partial_cmp(&self, other: &str) -> 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 Rem<&Percent> for Percent

§

type Output = Percent

The resulting type after applying the % operator.
source§

fn rem(self, other: &Percent) -> Self

Performs the % operation. Read more
source§

impl Rem<&Percent> for f64

§

type Output = f64

The resulting type after applying the % operator.
source§

fn rem(self, other: &Percent) -> Self

Performs the % operation. Read more
source§

impl Rem<&f64> for Percent

§

type Output = Percent

The resulting type after applying the % operator.
source§

fn rem(self, other: &f64) -> Self

Performs the % operation. Read more
source§

impl Rem<Percent> for Percent

§

type Output = Percent

The resulting type after applying the % operator.
source§

fn rem(self, other: Percent) -> Self

Performs the % operation. Read more
source§

impl Rem<Percent> for f64

§

type Output = f64

The resulting type after applying the % operator.
source§

fn rem(self, other: Percent) -> Self

Performs the % operation. Read more
source§

impl Rem<f64> for Percent

§

type Output = Percent

The resulting type after applying the % operator.
source§

fn rem(self, other: f64) -> Self

Performs the % operation. Read more
source§

impl Serialize for Percent

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<&Percent> for Percent

§

type Output = Percent

The resulting type after applying the - operator.
source§

fn sub(self, other: &Percent) -> Self

Performs the - operation. Read more
source§

impl Sub<&Percent> for f64

§

type Output = f64

The resulting type after applying the - operator.
source§

fn sub(self, other: &Percent) -> Self

Performs the - operation. Read more
source§

impl Sub<&f64> for Percent

§

type Output = Percent

The resulting type after applying the - operator.
source§

fn sub(self, other: &f64) -> Self

Performs the - operation. Read more
source§

impl Sub<Percent> for Percent

§

type Output = Percent

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl Sub<Percent> for f64

§

type Output = f64

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl Sub<f64> for Percent

§

type Output = Percent

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl StructuralPartialEq for Percent

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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToCompactString for Twhere T: Display,

source§

fn to_compact_string(&self) -> CompactString

Converts the given value to a CompactString. Read more
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.
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.
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>,