pub struct FixDec64<const P: u32> { /* private fields */ }
Expand description

A 64-bits primitive fixed-point decimal type, with about 18 significant digits.

See the module-level documentation for more information.

Implementations§

source§

impl<const P: u32> FixDec64<P>

source

pub const ZERO: Self = _

The zero value, 0.

source

pub const ONE: Self = _

The one value, 1.

source

pub const MAX: Self = _

The largest value, (263 - 1) / 10P.

source

pub const MIN: Self = _

The smallest value, -(263 / 10P).

source

pub const MIN_POSITIVE: Self = _

The smallest positive value, 10-P .

source

pub const fn abs(self) -> Self

Computes the absolute value of self.

Overflow behavior

The absolute value of MIN cannot be represented as this type, and attempting to calculate it will cause an overflow. This means that code in debug mode will trigger a panic on this case and optimized code will return MIN without a panic.

Examples
use primitive_fixed_point_decimal::FixDec64;
type Decimal = FixDec64::<4>;

assert_eq!(Decimal::ONE.abs(), Decimal::ONE);
assert_eq!(Decimal::MAX.abs(), Decimal::MAX);
assert_eq!((-Decimal::ONE).abs(), Decimal::ONE);
assert_eq!((-Decimal::MAX).abs(), Decimal::MAX);
assert_eq!(Decimal::ZERO.abs(), Decimal::ZERO);
source

pub const fn checked_abs(self) -> Option<Self>

Checked absolute value. Computes self.abs(), returning None if self == MIN.

Examples
use primitive_fixed_point_decimal::FixDec64;
type Decimal = FixDec64::<4>;

assert_eq!((-Decimal::ONE).checked_abs(), Some(Decimal::ONE));
assert_eq!(Decimal::MIN.checked_abs(), None);
source

pub const fn checked_add(self, rhs: Self) -> Option<Self>

Checked addition. Computes self + rhs, returning None if overflow occurred.

The right operand must have the same precision with self. So you can not add FixDec64::<4> by FixDec64::<5>.

If you really want to add a value with different precision, convert it by FixDec64::rescale first.

Examples
use std::str::FromStr;
use primitive_fixed_point_decimal::FixDec64;
type Decimal = FixDec64::<4>;

let left = Decimal::from_str("1.23").unwrap();
let right = Decimal::from_str("0.45").unwrap();

let res = Decimal::from_str("1.68").unwrap();
assert_eq!(left.checked_add(right), Some(res));
source

pub const fn checked_sub(self, rhs: Self) -> Option<Self>

Checked subtraction. Computes self - rhs, returning None if overflow occurred.

The right operand must have the same precision with self. So you can not subtract FixDec64::<4> by FixDec64::<5>.

If you really want to subtract a value with different precision, convert it by FixDec64::rescale first.

Examples
use std::str::FromStr;
use primitive_fixed_point_decimal::FixDec64;
type Decimal = FixDec64::<4>;

let left = Decimal::from_str("1.68").unwrap();
let right = Decimal::from_str("1.23").unwrap();

let res = Decimal::from_str("0.45").unwrap();
assert_eq!(left.checked_sub(right), Some(res));
source

pub const fn checked_mul_int(self, n: i64) -> Option<Self>

Checked multiplication with integer. Computes self * n, returning None if overflow occurred.

Examples
use std::str::FromStr;
use primitive_fixed_point_decimal::FixDec64;
type Decimal = FixDec64::<4>;

let dec = Decimal::from_str("0.123").unwrap();
let res = Decimal::from_str("1.23").unwrap();
assert_eq!(dec.checked_mul_int(10), Some(res));
source

pub const fn checked_div_int(self, n: i64) -> Option<Self>

Checked division with integer. Equivalent to FixDec64::checked_div_int_with_rounding with rounding=Rounding::Round.

Examples
use std::str::FromStr;
use primitive_fixed_point_decimal::FixDec64;
type Decimal = FixDec64::<4>;

let dec = Decimal::from_str("1.23").unwrap();
let res = Decimal::from_str("0.123").unwrap();
assert_eq!(dec.checked_div_int(10), Some(res));
assert_eq!(dec.checked_div_int(0), None);
source

pub const fn checked_div_int_with_rounding( self, n: i64, rounding: Rounding ) -> Option<Self>

Checked division with integer. Computes self / n, returning None if n == 0 or precison loss with Rounding::Unexpected specified.

Examples
use std::str::FromStr;
use primitive_fixed_point_decimal::{FixDec64, Rounding};
type Decimal = FixDec64::<4>;

let dec = Decimal::from_str("0.2").unwrap();
let res1 = Decimal::from_str("0.0666").unwrap();
let res2 = Decimal::from_str("0.0667").unwrap();
assert_eq!(dec.checked_div_int_with_rounding(3, Rounding::Floor), Some(res1));
assert_eq!(dec.checked_div_int_with_rounding(3, Rounding::Ceil), Some(res2));
assert_eq!(dec.checked_div_int_with_rounding(3, Rounding::Unexpected), None);
source

pub const fn checked_mul<const Q: u32, const R: u32>( self, rhs: FixDec64<Q> ) -> Option<FixDec64<R>>

Checked multiplication. Equivalent to FixDec64::checked_mul_with_rounding with rounding=Rounding::Round.

source

pub const fn checked_mul_with_rounding<const Q: u32, const R: u32>( self, rhs: FixDec64<Q>, rounding: Rounding ) -> Option<FixDec64<R>>

Checked multiplication. Computes self * rhs, returning None if overflow occurred, or precison loss with Rounding::Unexpected specified.

The right operand and the result both could have different precisions against Self. So you can multiple FixDec64::<4> by FixDec64::<3> and get a FixDec64::<2>.

Panics

Panics if P + Q - R > DIGITS.

Examples
use std::str::FromStr;
use primitive_fixed_point_decimal::{FixDec64, Rounding};
type Balance = FixDec64::<4>;
type FeeRate = FixDec64::<3>; // different precision

let balance = Balance::from_str("2").unwrap();
let rate = FeeRate::from_str("0.015").unwrap();

let fee = Balance::from_str("0.03").unwrap();
assert_eq!(balance.checked_mul_with_rounding(rate, Rounding::Round), Some(fee));
source

pub const fn checked_div<const Q: u32, const R: u32>( self, rhs: FixDec64<Q> ) -> Option<FixDec64<R>>

Checked division. Equivalent to FixDec64::checked_div_with_rounding with rounding=Rounding::Round.

source

pub const fn checked_div_with_rounding<const Q: u32, const R: u32>( self, rhs: FixDec64<Q>, rounding: Rounding ) -> Option<FixDec64<R>>

Checked division. Computes self / rhs, returning None if rhs == 0 or the division results in overflow, or precison loss with Rounding::Unexpected specified.

The right operand and the result both could have different precisions against Self. So you can divide FixDec64::<4> by FixDec64::<3> and get a FixDec64::<2>.

Panics

Panics if Q + R - P > DIGITS.

Examples
use std::str::FromStr;
use primitive_fixed_point_decimal::{FixDec64, Rounding};
type Balance = FixDec64::<4>;
type FeeRate = FixDec64::<3>; // different precision

let balance = Balance::from_str("2").unwrap();
let fee = Balance::from_str("0.03").unwrap();
let rate = FeeRate::from_str("0.015").unwrap();

assert_eq!(fee.checked_div_with_rounding(balance, Rounding::Round), Some(rate));
assert_eq!(fee.checked_div_with_rounding(rate, Rounding::Round), Some(balance));
source

pub const fn rescale<const Q: u32>(self) -> Option<FixDec64<Q>>

Rescale to another precision representation.

Fail if overflow occurred when to bigger precision, or losing significant digits when to smaller precision.

Examples:
use std::str::FromStr;
use primitive_fixed_point_decimal::FixDec64;
type Dec2 = FixDec64::<2>;
type Dec4 = FixDec64::<4>;
let d2 = Dec2::from_str("1.23").unwrap();
let d4 = Dec4::from_str("1.23").unwrap();
assert_eq!(d4.rescale::<2>().unwrap(), d2);
assert_eq!(d2.rescale::<4>().unwrap(), d4);
source

pub const fn is_neg(&self) -> bool

Return if negative.

source

pub const fn is_pos(&self) -> bool

Return if positive.

source

pub const fn is_zero(&self) -> bool

Return if zero.

source

pub const fn shrink_to(self, precision: i32) -> Self

Shrink to a lower precision. Equivalent to FixDec64::shrink_to_with_rounding with rounding=Rounding::Round.

source

pub const fn shrink_to_with_rounding( self, precision: i32, rounding: Rounding ) -> Option<Self>

Shrink to a lower precision. Fail if lossing significant precision with rounding=Rounding::Unexpected.

Negative precision argument means integer part.

Examples:
use std::str::FromStr;
use primitive_fixed_point_decimal::{FixDec64, Rounding};
type Decimal = FixDec64::<4>;
let d = Decimal::from_str("1.2378").unwrap();
assert_eq!(d.shrink_to_with_rounding(2, Rounding::Floor).unwrap(), Decimal::from_str("1.23").unwrap());
assert_eq!(d.shrink_to_with_rounding(2, Rounding::Ceil).unwrap(), Decimal::from_str("1.24").unwrap());
assert_eq!(d.shrink_to_with_rounding(2, Rounding::Round).unwrap(), Decimal::from_str("1.24").unwrap());
assert_eq!(d.shrink_to_with_rounding(2, Rounding::Unexpected), None);

// negative precision argument
type Decimal1 = FixDec64::<1>;
let d = Decimal1::from_str("1234.5").unwrap();
assert_eq!(d.shrink_to_with_rounding(-2, Rounding::Round).unwrap(), Decimal1::from_str("1200").unwrap());
source

pub const fn from_inner(inner: i64) -> Self

Construct from inner directly. This API is low-level. Use it carefully.

Making a FixDec64<P> from inner gets value: inner-P.

If you want to convert an integer to Fixdec keeping its value, use FixDec64::try_from.

Examples:
use std::str::FromStr;
use primitive_fixed_point_decimal::FixDec64;
type Decimal = FixDec64::<4>;
assert_eq!(Decimal::from_inner(12345), Decimal::from_str("1.2345").unwrap());
source

pub fn from_str_with_rounding( s: &str, rounding: Rounding ) -> Result<Self, ParseError>

Read decimal from string, with specified rounding kind.

Examples:
use std::str::FromStr;
use primitive_fixed_point_decimal::{Rounding, ParseError};
use primitive_fixed_point_decimal::FixDec64;
type Decimal = FixDec64::<4>;

fn check(origin: &str, rounding: Rounding, expect: &str) {
    let fd = Decimal::from_str_with_rounding(origin, rounding).unwrap();
    assert_eq!(fd, Decimal::from_str(expect).unwrap());
}
check("1.23456789", Rounding::Floor, "1.2345");
check("1.23456789", Rounding::Ceil, "1.2346");
check("1.23456789", Rounding::Round, "1.2346");
check("1.23455000", Rounding::Round, "1.2346");
check("1.23", Rounding::Round, "1.23");

assert_eq!(Decimal::from_str_with_rounding("1.23789", Rounding::Unexpected),
           Err(ParseError::Precision));

Trait Implementations§

source§

impl<const P: u32> Add for FixDec64<P>

§

type Output = FixDec64<P>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<const P: u32> AddAssign for FixDec64<P>

source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
source§

impl<const P: u32> Clone for FixDec64<P>

source§

fn clone(&self) -> FixDec64<P>

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<const P: u32> Debug for FixDec64<P>

source§

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

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

impl<const P: u32> Default for FixDec64<P>

source§

fn default() -> FixDec64<P>

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

impl<const P: u32> Display for FixDec64<P>

Format the decimal.

The tailing zeros of fraction are truncated by default, while the precision can be specified by {:.N}.

Examples:

use std::str::FromStr;
use primitive_fixed_point_decimal::FixDec64;
type Decimal = FixDec64::<4>;
let fd = Decimal::from_str("1.5670").unwrap();
assert_eq!(&format!("{}", fd), "1.567"); // omit tailing zeros
assert_eq!(&format!("{:.2}", fd), "1.57"); // rounding
source§

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

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

impl<const P: u32> FromStr for FixDec64<P>

source§

fn from_str(s: &str) -> Result<Self, ParseError>

Read decimal from string.

Equivalent to FixDec64::from_str_with_rounding with rounding=Rounding::Round.

§

type Err = ParseError

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

impl<const P: u32> Hash for FixDec64<P>

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 P: u32> Into<FixDec128<P>> for FixDec64<P>

source§

fn into(self) -> FixDec128<P>

Convert FixDec64 into FixDec128 with same precision.

source§

impl<const P: u32> Into<FixDec64<P>> for FixDec16<P>

source§

fn into(self) -> FixDec64<P>

Convert FixDec16 into FixDec64 with same precision.

source§

impl<const P: u32> Into<FixDec64<P>> for FixDec32<P>

source§

fn into(self) -> FixDec64<P>

Convert FixDec32 into FixDec64 with same precision.

source§

impl<const P: u32> Into<f32> for FixDec64<P>

source§

fn into(self) -> f32

Convert FixDec into f32.

Examples:
use primitive_fixed_point_decimal::FixDec64;
type Decimal = FixDec64::<2>;
let f: f32 = Decimal::try_from(123.45).unwrap().into();
assert_eq!(f, 123.45);
source§

impl<const P: u32> Into<f64> for FixDec64<P>

source§

fn into(self) -> f64

Convert FixDec into f64.

Examples:
use primitive_fixed_point_decimal::FixDec64;
type Decimal = FixDec64::<2>;
let f: f64 = Decimal::try_from(123.45).unwrap().into();
assert_eq!(f, 123.45);
source§

impl<const P: u32> Neg for FixDec64<P>

§

type Output = FixDec64<P>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl<const P: u32> Ord for FixDec64<P>

source§

fn cmp(&self, other: &FixDec64<P>) -> Ordering

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

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

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

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

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

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

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

impl<const P: u32> PartialEq for FixDec64<P>

source§

fn eq(&self, other: &FixDec64<P>) -> 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<const P: u32> PartialOrd for FixDec64<P>

source§

fn partial_cmp(&self, other: &FixDec64<P>) -> 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<const P: u32> Sub for FixDec64<P>

§

type Output = FixDec64<P>

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl<const P: u32> SubAssign for FixDec64<P>

source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
source§

impl<const P: u32> TryFrom<f32> for FixDec64<P>

source§

fn try_from(f: f32) -> Result<Self, Self::Error>

Try to convert f32 into FixDec. Fail if overflow occurred.

Examples:
use std::str::FromStr;
use primitive_fixed_point_decimal::FixDec64;
type Decimal = FixDec64::<2>;
assert_eq!(Decimal::try_from(123.456_f32).unwrap(), Decimal::from_str("123.46").unwrap());
§

type Error = ()

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

impl<const P: u32> TryFrom<f64> for FixDec64<P>

source§

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

Try to convert f64 into FixDec. Fail if overflow occurred.

Examples:
use std::str::FromStr;
use primitive_fixed_point_decimal::FixDec64;
type Decimal = FixDec64::<2>;
assert_eq!(Decimal::try_from(123.456_f64).unwrap(), Decimal::from_str("123.46").unwrap());
§

type Error = ()

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

impl<const P: u32> TryFrom<i128> for FixDec64<P>

source§

fn try_from(i: i128) -> Result<Self, Self::Error>

Try to convert i128 into FixDec. Fail if overflow occurred.

Examples:
use std::str::FromStr;
use primitive_fixed_point_decimal::FixDec64;
type Decimal = FixDec64::<2>;
assert_eq!(Decimal::try_from(100_i128).unwrap(), Decimal::from_str("100").unwrap());
§

type Error = ()

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

impl<const P: u32> TryFrom<i16> for FixDec64<P>

source§

fn try_from(i: i16) -> Result<Self, Self::Error>

Try to convert i16 into FixDec. Fail if overflow occurred.

Examples:
use std::str::FromStr;
use primitive_fixed_point_decimal::FixDec64;
type Decimal = FixDec64::<2>;
assert_eq!(Decimal::try_from(100_i16).unwrap(), Decimal::from_str("100").unwrap());
§

type Error = ()

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

impl<const P: u32> TryFrom<i32> for FixDec64<P>

source§

fn try_from(i: i32) -> Result<Self, Self::Error>

Try to convert i32 into FixDec. Fail if overflow occurred.

Examples:
use std::str::FromStr;
use primitive_fixed_point_decimal::FixDec64;
type Decimal = FixDec64::<2>;
assert_eq!(Decimal::try_from(100_i32).unwrap(), Decimal::from_str("100").unwrap());
§

type Error = ()

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

impl<const P: u32> TryFrom<i64> for FixDec64<P>

source§

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

Try to convert i64 into FixDec. Fail if overflow occurred.

Examples:
use std::str::FromStr;
use primitive_fixed_point_decimal::FixDec64;
type Decimal = FixDec64::<2>;
assert_eq!(Decimal::try_from(100_i64).unwrap(), Decimal::from_str("100").unwrap());
§

type Error = ()

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

impl<const P: u32> TryFrom<i8> for FixDec64<P>

source§

fn try_from(i: i8) -> Result<Self, Self::Error>

Try to convert i8 into FixDec. Fail if overflow occurred.

Examples:
use std::str::FromStr;
use primitive_fixed_point_decimal::FixDec64;
type Decimal = FixDec64::<2>;
assert_eq!(Decimal::try_from(100_i8).unwrap(), Decimal::from_str("100").unwrap());
§

type Error = ()

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

impl<const P: u32> TryFrom<u128> for FixDec64<P>

source§

fn try_from(i: u128) -> Result<Self, Self::Error>

Try to convert u128 into FixDec. Fail if overflow occurred.

Examples:
use std::str::FromStr;
use primitive_fixed_point_decimal::FixDec64;
type Decimal = FixDec64::<2>;
assert_eq!(Decimal::try_from(100_u128).unwrap(), Decimal::from_str("100").unwrap());
§

type Error = ()

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

impl<const P: u32> TryFrom<u16> for FixDec64<P>

source§

fn try_from(i: u16) -> Result<Self, Self::Error>

Try to convert u16 into FixDec. Fail if overflow occurred.

Examples:
use std::str::FromStr;
use primitive_fixed_point_decimal::FixDec64;
type Decimal = FixDec64::<2>;
assert_eq!(Decimal::try_from(100_u16).unwrap(), Decimal::from_str("100").unwrap());
§

type Error = ()

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

impl<const P: u32> TryFrom<u32> for FixDec64<P>

source§

fn try_from(i: u32) -> Result<Self, Self::Error>

Try to convert u32 into FixDec. Fail if overflow occurred.

Examples:
use std::str::FromStr;
use primitive_fixed_point_decimal::FixDec64;
type Decimal = FixDec64::<2>;
assert_eq!(Decimal::try_from(100_u32).unwrap(), Decimal::from_str("100").unwrap());
§

type Error = ()

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

impl<const P: u32> TryFrom<u64> for FixDec64<P>

source§

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

Try to convert u64 into FixDec. Fail if overflow occurred.

Examples:
use std::str::FromStr;
use primitive_fixed_point_decimal::FixDec64;
type Decimal = FixDec64::<2>;
assert_eq!(Decimal::try_from(100_u64).unwrap(), Decimal::from_str("100").unwrap());
§

type Error = ()

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

impl<const P: u32> TryFrom<u8> for FixDec64<P>

source§

fn try_from(i: u8) -> Result<Self, Self::Error>

Try to convert u8 into FixDec. Fail if overflow occurred.

Examples:
use std::str::FromStr;
use primitive_fixed_point_decimal::FixDec64;
type Decimal = FixDec64::<2>;
assert_eq!(Decimal::try_from(100_u8).unwrap(), Decimal::from_str("100").unwrap());
§

type Error = ()

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

impl<const P: u32> TryInto<FixDec16<P>> for FixDec64<P>

source§

fn try_into(self) -> Result<FixDec16<P>, Self::Error>

Try to convert FixDec64 into FixDec16 with same precision. Fail if overflow occurred.

§

type Error = ()

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

impl<const P: u32> TryInto<FixDec32<P>> for FixDec64<P>

source§

fn try_into(self) -> Result<FixDec32<P>, Self::Error>

Try to convert FixDec64 into FixDec32 with same precision. Fail if overflow occurred.

§

type Error = ()

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

impl<const P: u32> TryInto<FixDec64<P>> for FixDec128<P>

source§

fn try_into(self) -> Result<FixDec64<P>, Self::Error>

Try to convert FixDec128 into FixDec64 with same precision. Fail if overflow occurred.

§

type Error = ()

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

impl<const P: u32> Copy for FixDec64<P>

source§

impl<const P: u32> Eq for FixDec64<P>

source§

impl<const P: u32> StructuralEq for FixDec64<P>

source§

impl<const P: u32> StructuralPartialEq for FixDec64<P>

Auto Trait Implementations§

§

impl<const P: u32> RefUnwindSafe for FixDec64<P>

§

impl<const P: u32> Send for FixDec64<P>

§

impl<const P: u32> Sync for FixDec64<P>

§

impl<const P: u32> Unpin for FixDec64<P>

§

impl<const P: u32> UnwindSafe for FixDec64<P>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

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

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

§

type Error = Infallible

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

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

Performs the conversion.
source§

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

§

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

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

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

Performs the conversion.