Skip to main content

Decimal

Struct Decimal 

Source
pub struct Decimal<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32>(/* private fields */);
Expand description

Decimal number with at most MAX_DIGITS significant digits and at most DECIMAL_PLACES digits after the decimal point.

Why strings in strict mode. JSON numbers are IEEE-754 floats in serde_json (this crate does not enable arbitrary_precision), so values such as 1.1 cannot be represented exactly. Strict mode therefore accepts only JSON strings; lax mode also accepts numbers and converts them through f64, which may round.

Trailing zeros are ignored when checking digits, matching Pydantic (1.20 satisfies DECIMAL_PLACES = 1). Unlike Pydantic, integer digits are not additionally capped at MAX_DIGITS - DECIMAL_PLACES.

The JSON Schema is {"type":"string","format":"decimal"}. format is an application hint (not a JSON Schema 2020-12 built-in); a pattern is omitted because [rust_decimal] also accepts scientific notation.

Implementations§

Source§

impl<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> Decimal<MAX_DIGITS, DECIMAL_PLACES>

Source

pub fn new(value: RawDecimal) -> Result<Self, FieldError>

Validate digit constraints and wrap value.

Source

pub fn parse(value: &str) -> Result<Self, FieldError>

Parse a decimal string and validate digit constraints.

Source§

impl<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> Decimal<MAX_DIGITS, DECIMAL_PLACES>

Source

pub fn into_inner(self) -> RawDecimal

Unwrap the inner decimal.

Methods from Deref<Target = RawDecimal>§

pub const MIN: Decimal = MIN

pub const MAX: Decimal = MAX

pub const ZERO: Decimal = ZERO

pub const ONE: Decimal = ONE

pub const NEGATIVE_ONE: Decimal = NEGATIVE_ONE

pub const TWO: Decimal = TWO

pub const TEN: Decimal = TEN

pub const ONE_HUNDRED: Decimal = ONE_HUNDRED

pub const ONE_THOUSAND: Decimal = ONE_THOUSAND

pub const MAX_SCALE: u32 = MAX_SCALE_U32

pub const PI: Decimal

pub const HALF_PI: Decimal

pub const QUARTER_PI: Decimal

pub const TWO_PI: Decimal

pub const E: Decimal

pub const E_INVERSE: Decimal

pub fn array_string(&self) -> impl AsRef<str>

Returns a string representation that is similar to alloc::string::ToString but doesn’t require a heap allocation.

§Examples
assert_eq!(Decimal::from_str_exact("-0.001")?.array_string().as_ref(), "-0.001");

pub fn scale(&self) -> u32

Returns the scale of the decimal number, otherwise known as e.

§Example
let num = Decimal::new(1234, 3);
assert_eq!(num.scale(), 3u32);

pub fn mantissa(&self) -> i128

Returns the mantissa of the decimal number.

§Example

let num = dec!(-1.2345678);
assert_eq!(num.mantissa(), -12345678i128);
assert_eq!(num.scale(), 7);

pub fn is_zero(&self) -> bool

Returns true if this Decimal number is equivalent to zero.

§Example
let num = Decimal::ZERO;
assert!(num.is_zero());

pub fn is_integer(&self) -> bool

Returns true if this Decimal number has zero fractional part (is equal to an integer)

§Example
assert_eq!(dec!(5).is_integer(), true);
// Trailing zeros are also ignored
assert_eq!(dec!(5.0000).is_integer(), true);
// If there is a fractional part then it is not an integer
assert_eq!(dec!(5.1).is_integer(), false);

pub fn serialize(&self) -> [u8; 16]

Returns a serialized version of the decimal number. The resulting byte array will have the following representation:

  • Bytes 1-4: flags
  • Bytes 5-8: lo portion of m
  • Bytes 9-12: mid portion of m
  • Bytes 13-16: high portion of m

pub fn is_negative(&self) -> bool

👎Deprecated since 0.6.3:

please use is_sign_negative instead

Returns true if the decimal is negative.

pub fn is_positive(&self) -> bool

👎Deprecated since 0.6.3:

please use is_sign_positive instead

Returns true if the decimal is positive.

pub fn is_sign_negative(&self) -> bool

Returns true if the sign bit of the decimal is negative.

§Example
assert_eq!(true, Decimal::new(-1, 0).is_sign_negative());
assert_eq!(false, Decimal::new(1, 0).is_sign_negative());

pub fn is_sign_positive(&self) -> bool

Returns true if the sign bit of the decimal is positive.

§Example
assert_eq!(false, Decimal::new(-1, 0).is_sign_positive());
assert_eq!(true, Decimal::new(1, 0).is_sign_positive());

pub fn trunc(&self) -> Decimal

Returns a new Decimal integral with no fractional portion. This is a true truncation whereby no rounding is performed.

§Example
let pi = dec!(3.141);
assert_eq!(pi.trunc(), dec!(3));

// Negative numbers are similarly truncated without rounding
let neg = dec!(-1.98765);
assert_eq!(neg.trunc(), Decimal::NEGATIVE_ONE);

pub fn trunc_with_scale(&self, scale: u32) -> Decimal

Returns a new Decimal with the fractional portion delimited by scale. This is a true truncation whereby no rounding is performed.

§Example
let pi = dec!(3.141592);
assert_eq!(pi.trunc_with_scale(2), dec!(3.14));

// Negative numbers are similarly truncated without rounding
let neg = dec!(-1.98765);
assert_eq!(neg.trunc_with_scale(1), dec!(-1.9));

pub fn fract(&self) -> Decimal

Returns a new Decimal representing the fractional portion of the number.

§Example
let pi = Decimal::new(3141, 3);
let fract = Decimal::new(141, 3);
// note that it returns a decimal
assert_eq!(pi.fract(), fract);

pub fn abs(&self) -> Decimal

Computes the absolute value of self.

§Example
let num = Decimal::new(-3141, 3);
assert_eq!(num.abs().to_string(), "3.141");

pub fn floor(&self) -> Decimal

Returns the largest integer less than or equal to a number.

§Example
let num = Decimal::new(3641, 3);
assert_eq!(num.floor().to_string(), "3");

pub fn ceil(&self) -> Decimal

Returns the smallest integer greater than or equal to a number.

§Example
let num = Decimal::new(3141, 3);
assert_eq!(num.ceil().to_string(), "4");
let num = Decimal::new(3, 0);
assert_eq!(num.ceil().to_string(), "3");

pub fn normalize(&self) -> Decimal

Strips any trailing zero’s from a Decimal and converts -0 to 0.

§Example
let number = Decimal::from_str("3.100")?;
assert_eq!(number.normalize().to_string(), "3.1");

pub fn round(&self) -> Decimal

Returns a new Decimal number with no fractional portion (i.e. an integer). Rounding currently follows “Bankers Rounding” rules. e.g. 6.5 -> 6, 7.5 -> 8

§Example
// Demonstrating bankers rounding...
let number_down = Decimal::new(65, 1);
let number_up   = Decimal::new(75, 1);
assert_eq!(number_down.round().to_string(), "6");
assert_eq!(number_up.round().to_string(), "8");

pub fn round_dp_with_strategy( &self, dp: u32, strategy: RoundingStrategy, ) -> Decimal

Returns a new Decimal number with the specified number of decimal points for fractional portion. Rounding is performed using the provided [RoundingStrategy]

§Arguments
  • dp: the number of decimal points to round to.
  • strategy: the [RoundingStrategy] to use.
§Example
let tax = dec!(3.4395);
assert_eq!(tax.round_dp_with_strategy(2, RoundingStrategy::MidpointAwayFromZero).to_string(), "3.44");

pub fn round_dp(&self, dp: u32) -> Decimal

Returns a new Decimal number with the specified number of decimal points for fractional portion. Rounding currently follows “Bankers Rounding” rules. e.g. 6.5 -> 6, 7.5 -> 8

§Arguments
  • dp: the number of decimal points to round to.
§Example
let pi = dec!(3.1415926535897932384626433832);
assert_eq!(pi.round_dp(2).to_string(), "3.14");

pub fn round_sf(&self, digits: u32) -> Option<Decimal>

Returns Some(Decimal) number rounded to the specified number of significant digits. If the resulting number is unable to be represented by the Decimal number then None will be returned. When the number of significant figures of the Decimal being rounded is greater than the requested number of significant digits then rounding will be performed using MidpointNearestEven strategy.

§Arguments
  • digits: the number of significant digits to round to.
§Remarks

A significant figure is determined using the following rules:

  1. Non-zero digits are always significant.
  2. Zeros between non-zero digits are always significant.
  3. Leading zeros are never significant.
  4. Trailing zeros are only significant if the number contains a decimal point.
§Example

let value = dec!(305.459);
assert_eq!(value.round_sf(0), Some(dec!(0)));
assert_eq!(value.round_sf(1), Some(dec!(300)));
assert_eq!(value.round_sf(2), Some(dec!(310)));
assert_eq!(value.round_sf(3), Some(dec!(305)));
assert_eq!(value.round_sf(4), Some(dec!(305.5)));
assert_eq!(value.round_sf(5), Some(dec!(305.46)));
assert_eq!(value.round_sf(6), Some(dec!(305.459)));
assert_eq!(value.round_sf(7), Some(dec!(305.4590)));
assert_eq!(Decimal::MAX.round_sf(1), None);

let value = dec!(0.012301);
assert_eq!(value.round_sf(3), Some(dec!(0.0123)));

pub fn round_sf_with_strategy( &self, digits: u32, strategy: RoundingStrategy, ) -> Option<Decimal>

Returns Some(Decimal) number rounded to the specified number of significant digits. If the resulting number is unable to be represented by the Decimal number then None will be returned. When the number of significant figures of the Decimal being rounded is greater than the requested number of significant digits then rounding will be performed using the provided [RoundingStrategy].

§Arguments
  • digits: the number of significant digits to round to.
  • strategy: if required, the rounding strategy to use.
§Remarks

A significant figure is determined using the following rules:

  1. Non-zero digits are always significant.
  2. Zeros between non-zero digits are always significant.
  3. Leading zeros are never significant.
  4. Trailing zeros are only significant if the number contains a decimal point.
§Example

let value = dec!(305.459);
assert_eq!(value.round_sf_with_strategy(0, RoundingStrategy::ToZero), Some(dec!(0)));
assert_eq!(value.round_sf_with_strategy(1, RoundingStrategy::ToZero), Some(dec!(300)));
assert_eq!(value.round_sf_with_strategy(2, RoundingStrategy::ToZero), Some(dec!(300)));
assert_eq!(value.round_sf_with_strategy(3, RoundingStrategy::ToZero), Some(dec!(305)));
assert_eq!(value.round_sf_with_strategy(4, RoundingStrategy::ToZero), Some(dec!(305.4)));
assert_eq!(value.round_sf_with_strategy(5, RoundingStrategy::ToZero), Some(dec!(305.45)));
assert_eq!(value.round_sf_with_strategy(6, RoundingStrategy::ToZero), Some(dec!(305.459)));
assert_eq!(value.round_sf_with_strategy(7, RoundingStrategy::ToZero), Some(dec!(305.4590)));
assert_eq!(Decimal::MAX.round_sf_with_strategy(1, RoundingStrategy::ToZero), Some(dec!(70000000000000000000000000000)));

let value = dec!(0.012301);
assert_eq!(value.round_sf_with_strategy(3, RoundingStrategy::AwayFromZero), Some(dec!(0.0124)));

pub fn unpack(&self) -> UnpackedDecimal

Convert Decimal to an internal representation of the underlying struct. This is useful for debugging the internal state of the object.

§Important Disclaimer

This is primarily intended for library maintainers. The internal representation of a Decimal is considered “unstable” for public use.

§Example

let pi = dec!(3.1415926535897932384626433832);
assert_eq!(format!("{:?}", pi), "3.1415926535897932384626433832");
assert_eq!(format!("{:?}", pi.unpack()), "UnpackedDecimal { \
    negative: false, scale: 28, hi: 1703060790, mid: 185874565, lo: 1102470952 \
}");

pub fn as_i128(&self) -> i128

Converts this Decimal to an i128, truncating any fractional part.

This is the infallible equivalent of ToPrimitive::to_i128.

pub fn as_f64(&self) -> f64

Converts this Decimal to an f64.

This is the infallible equivalent of ToPrimitive::to_f64.

Trait Implementations§

Source§

impl<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> AsRef<Decimal> for Decimal<MAX_DIGITS, DECIMAL_PLACES>

Source§

fn as_ref(&self) -> &RawDecimal

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> Clone for Decimal<MAX_DIGITS, DECIMAL_PLACES>

Source§

fn clone(&self) -> Decimal<MAX_DIGITS, DECIMAL_PLACES>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> Copy for Decimal<MAX_DIGITS, DECIMAL_PLACES>

Source§

impl<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> Debug for Decimal<MAX_DIGITS, DECIMAL_PLACES>

Source§

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

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

impl<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> Deref for Decimal<MAX_DIGITS, DECIMAL_PLACES>

Source§

type Target = Decimal

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'de, const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> Deserialize<'de> for Decimal<MAX_DIGITS, DECIMAL_PLACES>

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<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> Display for Decimal<MAX_DIGITS, DECIMAL_PLACES>

Source§

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

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

impl<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> Dump for Decimal<MAX_DIGITS, DECIMAL_PLACES>

Source§

fn serialize_dump<S: Serializer>( &self, serializer: S, opts: &DumpOptions, ) -> Result<S::Ok, S::Error>

Serialize directly when supported, preserving dump semantics. Read more
Source§

fn dump(&self, opts: &DumpOptions) -> Result<Value, DumpError>

Serialize with opts applied. Read more
Source§

impl<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> Eq for Decimal<MAX_DIGITS, DECIMAL_PLACES>

Source§

impl<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> From<Decimal<MAX_DIGITS, DECIMAL_PLACES>> for Decimal

Source§

fn from(value: Decimal<MAX_DIGITS, DECIMAL_PLACES>) -> Self

Converts to this type from the input type.
Source§

impl<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> From<Decimal<MAX_DIGITS, DECIMAL_PLACES>> for String

Source§

fn from(value: Decimal<MAX_DIGITS, DECIMAL_PLACES>) -> Self

Converts to this type from the input type.
Source§

impl<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> Hash for Decimal<MAX_DIGITS, DECIMAL_PLACES>

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<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> Ord for Decimal<MAX_DIGITS, DECIMAL_PLACES>

Source§

fn cmp(&self, other: &Decimal<MAX_DIGITS, DECIMAL_PLACES>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

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

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

impl<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> PartialEq for Decimal<MAX_DIGITS, DECIMAL_PLACES>

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> PartialOrd for Decimal<MAX_DIGITS, DECIMAL_PLACES>

Source§

fn partial_cmp( &self, other: &Decimal<MAX_DIGITS, DECIMAL_PLACES>, ) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> Schema for Decimal<MAX_DIGITS, DECIMAL_PLACES>

Source§

fn schema(_: &mut SchemaRegistry) -> SchemaObject

The schema definition of this type. Use SchemaRegistry::subschema for nested types.
Source§

fn schema_name() -> Option<&'static str>

Stable component name. Named types are emitted once under components.schemas and referenced with $ref.
Source§

impl<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> Serialize for Decimal<MAX_DIGITS, DECIMAL_PLACES>

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<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> StructuralPartialEq for Decimal<MAX_DIGITS, DECIMAL_PLACES>

Source§

impl<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> TryFrom<&str> for Decimal<MAX_DIGITS, DECIMAL_PLACES>

Source§

type Error = FieldError

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

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

Performs the conversion.
Source§

impl<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> TryFrom<Decimal> for Decimal<MAX_DIGITS, DECIMAL_PLACES>

Source§

type Error = FieldError

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

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

Performs the conversion.
Source§

impl<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> TryFrom<String> for Decimal<MAX_DIGITS, DECIMAL_PLACES>

Source§

type Error = FieldError

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

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

Performs the conversion.
Source§

impl<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> Validate for Decimal<MAX_DIGITS, DECIMAL_PLACES>

Source§

fn prepare(input: &mut Value, ctx: &mut ValidationContext)

Check and normalise the raw input for this type in place.
Source§

fn validate(&self, _ctx: &mut ValidationContext)

Check invariants of the deserialized value.

Auto Trait Implementations§

§

impl<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> Freeze for Decimal<MAX_DIGITS, DECIMAL_PLACES>

§

impl<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> RefUnwindSafe for Decimal<MAX_DIGITS, DECIMAL_PLACES>

§

impl<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> Send for Decimal<MAX_DIGITS, DECIMAL_PLACES>

§

impl<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> Sync for Decimal<MAX_DIGITS, DECIMAL_PLACES>

§

impl<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> Unpin for Decimal<MAX_DIGITS, DECIMAL_PLACES>

§

impl<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> UnsafeUnpin for Decimal<MAX_DIGITS, DECIMAL_PLACES>

§

impl<const MAX_DIGITS: u32, const DECIMAL_PLACES: u32> UnwindSafe for Decimal<MAX_DIGITS, DECIMAL_PLACES>

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
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

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

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.