Positive

Struct Positive 

Source
pub struct Positive(pub Decimal);
Expand description

A wrapper type that represents a guaranteed positive decimal value.

This type encapsulates a Decimal value and ensures through its API that the contained value is always positive (greater than or equal to zero).

Tuple Fields§

§0: Decimal

Implementations§

Source§

impl Positive

Source

pub const ZERO: Positive = crate::constants::ZERO

A zero value represented as a Positive value.

Source

pub const ONE: Positive = crate::constants::ONE

A value of one represented as a Positive value.

Source

pub const TWO: Positive = crate::constants::TWO

A value of two represented as a Positive value.

Source

pub const THREE: Positive = crate::constants::THREE

A value of three represented as a Positive value.

Source

pub const FOUR: Positive = crate::constants::FOUR

A value of four represented as a Positive value.

Source

pub const FIVE: Positive = crate::constants::FIVE

A value of five represented as a Positive value.

Source

pub const SIX: Positive = crate::constants::SIX

A value of six represented as a Positive value.

Source

pub const SEVEN: Positive = crate::constants::SEVEN

A value of seven represented as a Positive value.

Source

pub const EIGHT: Positive = crate::constants::EIGHT

A value of eight represented as a Positive value.

Source

pub const NINE: Positive = crate::constants::NINE

A value of nine represented as a Positive value.

Source

pub const TEN: Positive = crate::constants::TEN

A value of ten represented as a Positive value.

Source

pub const FIFTEEN: Positive = crate::constants::FIFTEEN

A value of fifteen represented as a Positive value.

Source

pub const TWENTY: Positive = crate::constants::TWENTY

A value of twenty represented as a Positive value.

Source

pub const TWENTY_FIVE: Positive = crate::constants::TWENTY_FIVE

A value of twenty-five represented as a Positive value.

Source

pub const THIRTY: Positive = crate::constants::THIRTY

A value of thirty represented as a Positive value.

Source

pub const THIRTY_FIVE: Positive = crate::constants::THIRTY_FIVE

A value of thirty-five represented as a Positive value.

Source

pub const FORTY: Positive = crate::constants::FORTY

A value of forty represented as a Positive value.

Source

pub const FORTY_FIVE: Positive = crate::constants::FORTY_FIVE

A value of forty-five represented as a Positive value.

Source

pub const FIFTY: Positive = crate::constants::FIFTY

A value of fifty represented as a Positive value.

Source

pub const FIFTY_FIVE: Positive = crate::constants::FIFTY_FIVE

A value of fifty-five represented as a Positive value.

Source

pub const SIXTY: Positive = crate::constants::SIXTY

A value of sixty represented as a Positive value.

Source

pub const SIXTY_FIVE: Positive = crate::constants::SIXTY_FIVE

A value of sixty-five represented as a Positive value.

Source

pub const SEVENTY: Positive = crate::constants::SEVENTY

A value of seventy represented as a Positive value.

Source

pub const SEVENTY_FIVE: Positive = crate::constants::SEVENTY_FIVE

A value of seventy-five represented as a Positive value.

Source

pub const EIGHTY: Positive = crate::constants::EIGHTY

A value of eighty represented as a Positive value.

Source

pub const EIGHTY_FIVE: Positive = crate::constants::EIGHTY_FIVE

A value of eighty-five represented as a Positive value.

Source

pub const NINETY: Positive = crate::constants::NINETY

A value of ninety represented as a Positive value.

Source

pub const NINETY_FIVE: Positive = crate::constants::NINETY_FIVE

A value of ninety-five represented as a Positive value.

Source

pub const HUNDRED: Positive = crate::constants::HUNDRED

A value of one hundred represented as a Positive value.

Source

pub const TWO_HUNDRED: Positive = crate::constants::TWO_HUNDRED

A value of two hundred represented as a Positive value.

Source

pub const THREE_HUNDRED: Positive = crate::constants::THREE_HUNDRED

A value of three hundred represented as a Positive value.

Source

pub const FOUR_HUNDRED: Positive = crate::constants::FOUR_HUNDRED

A value of four hundred represented as a Positive value.

Source

pub const FIVE_HUNDRED: Positive = crate::constants::FIVE_HUNDRED

A value of five hundred represented as a Positive value.

Source

pub const SIX_HUNDRED: Positive = crate::constants::SIX_HUNDRED

A value of six hundred represented as a Positive value.

Source

pub const SEVEN_HUNDRED: Positive = crate::constants::SEVEN_HUNDRED

A value of seven hundred represented as a Positive value.

Source

pub const EIGHT_HUNDRED: Positive = crate::constants::EIGHT_HUNDRED

A value of eight hundred represented as a Positive value.

Source

pub const NINE_HUNDRED: Positive = crate::constants::NINE_HUNDRED

A value of nine hundred represented as a Positive value.

Source

pub const THOUSAND: Positive = crate::constants::THOUSAND

A value of one thousand represented as a Positive value.

Source

pub const TWO_THOUSAND: Positive = crate::constants::TWO_THOUSAND

A value of two thousand represented as a Positive value.

Source

pub const THREE_THOUSAND: Positive = crate::constants::THREE_THOUSAND

A value of three thousand represented as a Positive value.

Source

pub const FOUR_THOUSAND: Positive = crate::constants::FOUR_THOUSAND

A value of four thousand represented as a Positive value.

Source

pub const FIVE_THOUSAND: Positive = crate::constants::FIVE_THOUSAND

A value of five thousand represented as a Positive value.

Source

pub const SIX_THOUSAND: Positive = crate::constants::SIX_THOUSAND

A value of six thousand represented as a Positive value.

Source

pub const SEVEN_THOUSAND: Positive = crate::constants::SEVEN_THOUSAND

A value of seven thousand represented as a Positive value.

Source

pub const EIGHT_THOUSAND: Positive = crate::constants::EIGHT_THOUSAND

A value of eight thousand represented as a Positive value.

Source

pub const NINE_THOUSAND: Positive = crate::constants::NINE_THOUSAND

A value of nine thousand represented as a Positive value.

Source

pub const TEN_THOUSAND: Positive = crate::constants::TEN_THOUSAND

A value of ten thousand represented as a Positive value.

Source

pub const PI: Positive = crate::constants::PI

The mathematical constant π (pi) represented as a Positive value.

Source

pub const E: Positive = crate::constants::E

The mathematical constant e (Euler’s number) represented as a Positive value.

Source

pub const INFINITY: Positive = crate::constants::INFINITY

Represents the maximum positive value possible (effectively infinity).

Source

pub fn new(value: f64) -> Result<Self, PositiveError>

Creates a new Positive value from a 64-bit floating-point number.

Source

pub fn new_decimal(value: Decimal) -> Result<Self, PositiveError>

Creates a new Positive value directly from a Decimal.

Source

pub fn value(&self) -> Decimal

Returns the inner Decimal value.

Source

pub fn to_dec(&self) -> Decimal

Returns the inner Decimal value (alias for value()).

Source

pub fn to_dec_ref(&self) -> &Decimal

Returns the inner Decimal ref.

Source

pub fn to_f64(&self) -> f64

Converts the value to a 64-bit floating-point number.

§Panics

This method will panic if the conversion fails. Use to_f64_checked() or to_f64_lossy() for non-panicking alternatives.

Source

pub fn to_f64_checked(&self) -> Option<f64>

Converts the value to f64, returning None if conversion fails.

Source

pub fn to_f64_lossy(&self) -> f64

Converts the value to f64 with lossy conversion (returns 0.0 on failure).

Source

pub fn to_i64(&self) -> i64

Converts the value to a 64-bit signed integer.

§Panics

This method will panic if the conversion fails. Use to_i64_checked() for a non-panicking alternative.

Source

pub fn to_i64_checked(&self) -> Option<i64>

Converts the value to i64, returning None if conversion fails.

Source

pub fn to_u64(&self) -> u64

Converts the inner value to a u64.

§Panics

This method will panic if the conversion fails. Use to_u64_checked() for a non-panicking alternative.

Source

pub fn to_u64_checked(&self) -> Option<u64>

Converts the value to u64, returning None if conversion fails.

Source

pub fn to_usize(&self) -> usize

Converts the value to a usize.

§Panics

This method will panic if the conversion fails. Use to_usize_checked() for a non-panicking alternative.

Source

pub fn to_usize_checked(&self) -> Option<usize>

Converts the value to usize, returning None if conversion fails.

Source

pub fn max(self, other: Positive) -> Positive

Returns the maximum of two Positive values.

Source

pub fn min(self, other: Positive) -> Positive

Returns the minimum of two Positive values.

Source

pub fn floor(&self) -> Positive

Rounds the value down to the nearest integer.

Source

pub fn powi(&self, n: i64) -> Positive

Raises this value to an integer power.

Source

pub fn pow(&self, n: Positive) -> Positive

Computes the result of raising the current value to the power of the given exponent.

Source

pub fn powu(&self, n: u64) -> Positive

Raises the current value to the power of n using unsigned integer exponentiation.

Source

pub fn powd(&self, p0: Decimal) -> Positive

Raises this value to a decimal power.

Source

pub fn round(&self) -> Positive

Rounds the value to the nearest integer.

Source

pub fn round_to_nice_number(&self) -> Positive

Rounds the current value to a “nice” number, based on its magnitude.

Source

pub fn sqrt(&self) -> Positive

Calculates the square root of the value.

§Panics

This method will panic if the square root calculation fails. Use sqrt_checked() for a non-panicking alternative.

Source

pub fn sqrt_checked(&self) -> Result<Positive, PositiveError>

Calculates the square root, returning an error if it fails.

Source

pub fn ln(&self) -> Positive

Calculates the natural logarithm of the value.

Source

pub fn round_to(&self, decimal_places: u32) -> Positive

Rounds the value to a specified number of decimal places.

Source

pub fn format_fixed_places(&self, decimal_places: u32) -> String

Formats the value with a fixed number of decimal places.

Source

pub fn exp(&self) -> Positive

Calculates the exponential function e^x for this value.

Source

pub fn clamp(&self, min: Positive, max: Positive) -> Positive

Clamps the value between a minimum and maximum.

Source

pub fn is_zero(&self) -> bool

Checks if the value is exactly zero.

Source

pub fn ceiling(&self) -> Positive

Returns the smallest integer greater than or equal to the value.

Source

pub fn log10(&self) -> Positive

Computes the base-10 logarithm of the value.

Source

pub fn sub_or_zero(&self, other: &Decimal) -> Positive

Subtracts a decimal value, returning zero if the result would be negative.

Source

pub fn sub_or_none(&self, other: &Decimal) -> Option<Positive>

Subtracts a decimal value, returning None if the result would be negative.

Source

pub fn checked_sub(&self, rhs: &Self) -> Result<Self, PositiveError>

Checked subtraction that returns Result instead of panicking.

Source

pub fn saturating_sub(&self, rhs: &Self) -> Self

Saturating subtraction that returns ZERO instead of negative.

Source

pub fn checked_div(&self, rhs: &Self) -> Result<Self, PositiveError>

Checked division that returns Result instead of panicking.

Source

pub fn is_multiple(&self, other: f64) -> bool

Checks whether the value is a multiple of another f64 value.

Source

pub fn is_multiple_of(&self, other: &Positive) -> bool

Checks whether the value is a multiple of another Positive value.

Source

pub const unsafe fn new_unchecked(value: Decimal) -> Self

Creates a new Positive value without checking if the value is non-negative.

§Safety

The caller must ensure that value >= 0. Using this with a negative value will violate the invariant of the Positive type and may cause undefined behavior in code that relies on the positivity guarantee.

§Example
use positive::Positive;
use rust_decimal_macros::dec;

// SAFETY: We know 5.0 is positive
let value = unsafe { Positive::new_unchecked(dec!(5.0)) };
assert_eq!(value.to_f64(), 5.0);

Trait Implementations§

Source§

impl AbsDiffEq for Positive

Source§

type Epsilon = Decimal

Used for specifying relative comparisons.
Source§

fn default_epsilon() -> Self::Epsilon

The default tolerance to use when testing values that are close together. Read more
Source§

fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool

A test for equality that uses the absolute difference to compute the approximate equality of two numbers.
Source§

fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool

The inverse of AbsDiffEq::abs_diff_eq.
Source§

impl Add<&Decimal> for Positive

Source§

type Output = Positive

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Add<&Positive> for Decimal

Source§

type Output = Decimal

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Positive) -> Decimal

Performs the + operation. Read more
Source§

impl Add<Decimal> for Positive

Source§

type Output = Positive

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Decimal) -> Positive

Performs the + operation. Read more
Source§

impl Add<Positive> for Decimal

Source§

type Output = Decimal

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Positive) -> Decimal

Performs the + operation. Read more
Source§

impl Add<Positive> for f64

Source§

type Output = f64

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Add<f64> for Positive

Source§

type Output = Positive

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Add for Positive

Source§

type Output = Positive

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl AddAssign<&Positive> for Decimal

Source§

fn add_assign(&mut self, rhs: &Positive)

Performs the += operation. Read more
Source§

impl AddAssign<Decimal> for Positive

Source§

fn add_assign(&mut self, rhs: Decimal)

Performs the += operation. Read more
Source§

impl AddAssign<Positive> for Decimal

Source§

fn add_assign(&mut self, rhs: Positive)

Performs the += operation. Read more
Source§

impl AddAssign for Positive

Source§

fn add_assign(&mut self, other: Positive)

Performs the += operation. Read more
Source§

impl Clone for Positive

Source§

fn clone(&self) -> Positive

Returns a duplicate 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 Positive

Source§

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

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

impl Default for Positive

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for Positive

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 Positive

Source§

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

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

impl Div<&Decimal> for Positive

Source§

type Output = Positive

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl Div<Decimal> for Positive

Source§

type Output = Positive

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Decimal) -> Positive

Performs the / operation. Read more
Source§

impl Div<Positive> for Decimal

Source§

type Output = Decimal

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Positive) -> Decimal

Performs the / operation. Read more
Source§

impl Div<Positive> for f64

Source§

type Output = f64

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Positive) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<f64> for &Positive

Source§

type Output = Positive

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f64) -> Positive

Performs the / operation. Read more
Source§

impl Div<f64> for Positive

Source§

type Output = Positive

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f64) -> Positive

Performs the / operation. Read more
Source§

impl Div for &Positive

Source§

type Output = Positive

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl Div for Positive

Source§

type Output = Positive

The resulting type after applying the / operator.
Source§

fn div(self, other: Positive) -> Self::Output

Performs the / operation. Read more
Source§

impl From<&Positive> for Decimal

Source§

fn from(pos: &Positive) -> Self

Converts to this type from the input type.
Source§

impl From<&Positive> for Positive

Source§

fn from(value: &Positive) -> Self

Converts to this type from the input type.
Source§

impl From<&Positive> for f64

Source§

fn from(value: &Positive) -> Self

Converts to this type from the input type.
Source§

impl From<Positive> for Decimal

Source§

fn from(value: Positive) -> Self

Converts to this type from the input type.
Source§

impl From<Positive> for f64

Source§

fn from(value: Positive) -> Self

Converts to this type from the input type.
Source§

impl From<Positive> for u64

Source§

fn from(pos_u64: Positive) -> Self

Converts to this type from the input type.
Source§

impl From<Positive> for usize

Source§

fn from(value: Positive) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Positive

Source§

type Err = String

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 Hash for Positive

Source§

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

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 Mul<Decimal> for Positive

Source§

type Output = Positive

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Decimal) -> Positive

Performs the * operation. Read more
Source§

impl Mul<Positive> for Decimal

Source§

type Output = Decimal

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Positive) -> Decimal

Performs the * operation. Read more
Source§

impl Mul<Positive> for f64

Source§

type Output = f64

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul<f64> for Positive

Source§

type Output = Positive

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f64) -> Positive

Performs the * operation. Read more
Source§

impl Mul for Positive

Source§

type Output = Positive

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl MulAssign<&Positive> for Decimal

Source§

fn mul_assign(&mut self, rhs: &Positive)

Performs the *= operation. Read more
Source§

impl MulAssign<Decimal> for Positive

Source§

fn mul_assign(&mut self, rhs: Decimal)

Performs the *= operation. Read more
Source§

impl MulAssign<Positive> for Decimal

Source§

fn mul_assign(&mut self, rhs: Positive)

Performs the *= operation. Read more
Source§

impl Neg for Positive

Source§

type Output = Positive

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl Ord for Positive

Source§

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

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

impl PartialEq<&Positive> for Positive

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<&Positive> for f64

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Decimal> for Positive

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Positive> for Decimal

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Positive> for f64

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<f64> for &Positive

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<f64> for Positive

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for Positive

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd<&Positive> for f64

Source§

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

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

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

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<Decimal> for Positive

Source§

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

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

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

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<Positive> for f64

Source§

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

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

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

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<f64> for &Positive

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

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

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

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<f64> for Positive

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

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

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

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd for Positive

Source§

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

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

fn le(&self, other: &Self) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
Source§

impl RelativeEq for Positive

Source§

fn default_max_relative() -> Self::Epsilon

The default relative tolerance for testing values that are far-apart. Read more
Source§

fn relative_eq( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool

A test for equality that uses a relative comparison if the values are far apart.
Source§

fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool

The inverse of RelativeEq::relative_eq.
Source§

impl Serialize for Positive

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<&Decimal> for Positive

Source§

type Output = Positive

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Sub<&Positive> for Decimal

Source§

type Output = Decimal

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Positive) -> Decimal

Performs the - operation. Read more
Source§

impl Sub<Decimal> for Positive

Source§

type Output = Positive

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Decimal) -> Positive

Performs the - operation. Read more
Source§

impl Sub<Positive> for Decimal

Source§

type Output = Decimal

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Positive) -> Decimal

Performs the - operation. Read more
Source§

impl Sub<Positive> for f64

Source§

type Output = f64

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Sub<f64> for Positive

Source§

type Output = Positive

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Sub for Positive

Source§

type Output = Positive

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<'a> Sum<&'a Positive> for Positive

Source§

fn sum<I: Iterator<Item = &'a Positive>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl Sum for Positive

Source§

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

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl TryFrom<&Decimal> for Positive

Source§

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

Attempts to convert a &Decimal to a Positive value.

§Errors

Returns PositiveError if the value is negative.

Source§

type Error = PositiveError

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

impl TryFrom<Decimal> for Positive

Source§

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

Attempts to convert a Decimal to a Positive value.

§Errors

Returns PositiveError if the value is negative.

Source§

type Error = PositiveError

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

impl TryFrom<f64> for Positive

Source§

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

Attempts to convert an f64 to a Positive value.

§Errors

Returns PositiveError if the value is negative, NaN, or cannot be converted to Decimal.

Source§

type Error = PositiveError

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

impl TryFrom<i64> for Positive

Source§

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

Attempts to convert an i64 to a Positive value.

§Errors

Returns PositiveError if the value is negative.

Source§

type Error = PositiveError

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

impl TryFrom<u64> for Positive

Source§

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

Attempts to convert a u64 to a Positive value.

§Errors

This conversion is infallible for u64 since all values are non-negative.

Source§

type Error = PositiveError

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

impl TryFrom<usize> for Positive

Source§

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

Attempts to convert a usize to a Positive value.

§Errors

Returns PositiveError if the value cannot be converted to Decimal.

Source§

type Error = PositiveError

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

impl Copy for Positive

Source§

impl Eq for Positive

Source§

impl StructuralPartialEq for Positive

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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§

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>,

Source§

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>,

Source§

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>,