cosmwasm_std

Struct SignedDecimal

Source
pub struct SignedDecimal(/* private fields */);
Expand description

A signed fixed-point decimal value with 18 fractional digits, i.e. SignedDecimal(1_000_000_000_000_000_000) == 1.0

The greatest possible value that can be represented is 170141183460469231731.687303715884105727 (which is (2^127 - 1) / 10^18) and the smallest is -170141183460469231731.687303715884105728 (which is -2^127 / 10^18).

Implementations§

Source§

impl SignedDecimal

Source

pub const DECIMAL_PLACES: u32 = 18u32

The number of decimal places. Since decimal types are fixed-point rather than floating-point, this is a constant.

Source

pub const MAX: Self = _

The largest value that can be represented by this signed decimal type.

§Examples
assert_eq!(SignedDecimal::MAX.to_string(), "170141183460469231731.687303715884105727");
Source

pub const MIN: Self = _

The smallest value that can be represented by this signed decimal type.

§Examples
assert_eq!(SignedDecimal::MIN.to_string(), "-170141183460469231731.687303715884105728");
Source

pub const fn new(value: Int128) -> Self

Creates a SignedDecimal(value) This is equivalent to SignedDecimal::from_atomics(value, 18) but usable in a const context.

§Examples
assert_eq!(SignedDecimal::new(Int128::one()).to_string(), "0.000000000000000001");
Source

pub const fn raw(value: i128) -> Self

Creates a SignedDecimal(Int128(value)) This is equivalent to SignedDecimal::from_atomics(value, 18) but usable in a const context.

§Examples
assert_eq!(SignedDecimal::raw(1234i128).to_string(), "0.000000000000001234");
Source

pub const fn one() -> Self

Create a 1.0 SignedDecimal

Source

pub const fn negative_one() -> Self

Create a -1.0 SignedDecimal

Source

pub const fn zero() -> Self

Create a 0.0 SignedDecimal

Source

pub fn percent(x: i64) -> Self

Convert x% into SignedDecimal

Source

pub fn permille(x: i64) -> Self

Convert permille (x/1000) into SignedDecimal

Source

pub fn bps(x: i64) -> Self

Convert basis points (x/10000) into SignedDecimal

Source

pub fn from_atomics( atomics: impl Into<Int128>, decimal_places: u32, ) -> Result<Self, SignedDecimalRangeExceeded>

Creates a signed decimal from a number of atomic units and the number of decimal places. The inputs will be converted internally to form a signed decimal with 18 decimal places. So the input 123 and 2 will create the decimal 1.23.

Using 18 decimal places is slightly more efficient than other values as no internal conversion is necessary.

§Examples
let a = SignedDecimal::from_atomics(Int128::new(1234), 3).unwrap();
assert_eq!(a.to_string(), "1.234");

let a = SignedDecimal::from_atomics(1234i128, 0).unwrap();
assert_eq!(a.to_string(), "1234");

let a = SignedDecimal::from_atomics(1i64, 18).unwrap();
assert_eq!(a.to_string(), "0.000000000000000001");

let a = SignedDecimal::from_atomics(-1i64, 18).unwrap();
assert_eq!(a.to_string(), "-0.000000000000000001");
Source

pub fn from_ratio( numerator: impl Into<Int128>, denominator: impl Into<Int128>, ) -> Self

Returns the ratio (numerator / denominator) as a SignedDecimal

§Examples
assert_eq!(
    SignedDecimal::from_ratio(1, 3).to_string(),
    "0.333333333333333333"
);
Source

pub fn checked_from_ratio( numerator: impl Into<Int128>, denominator: impl Into<Int128>, ) -> Result<Self, CheckedFromRatioError>

Returns the ratio (numerator / denominator) as a SignedDecimal

§Examples
assert_eq!(
    SignedDecimal::checked_from_ratio(1, 3).unwrap().to_string(),
    "0.333333333333333333"
);
assert_eq!(
    SignedDecimal::checked_from_ratio(1, 0),
    Err(CheckedFromRatioError::DivideByZero)
);
Source

pub const fn is_zero(&self) -> bool

Returns true if the number is 0

Source

pub const fn is_negative(&self) -> bool

Returns true if the number is negative (< 0)

Source

pub const fn atomics(&self) -> Int128

A decimal is an integer of atomic units plus a number that specifies the position of the decimal dot. So any decimal can be expressed as two numbers.

§Examples
// Value with whole and fractional part
let a = SignedDecimal::from_str("1.234").unwrap();
assert_eq!(a.decimal_places(), 18);
assert_eq!(a.atomics(), Int128::new(1234000000000000000));

// Smallest possible value
let b = SignedDecimal::from_str("0.000000000000000001").unwrap();
assert_eq!(b.decimal_places(), 18);
assert_eq!(b.atomics(), Int128::new(1));
Source

pub const fn decimal_places(&self) -> u32

The number of decimal places. This is a constant value for now but this could potentially change as the type evolves.

See also SignedDecimal::atomics().

Source

pub fn trunc(&self) -> Self

Rounds value by truncating the decimal places.

§Examples
assert!(SignedDecimal::from_str("0.6").unwrap().trunc().is_zero());
assert_eq!(SignedDecimal::from_str("-5.8").unwrap().trunc().to_string(), "-5");
Source

pub fn floor(&self) -> Self

Rounds value down after decimal places. Panics on overflow.

§Examples
assert!(SignedDecimal::from_str("0.6").unwrap().floor().is_zero());
assert_eq!(SignedDecimal::from_str("-5.2").unwrap().floor().to_string(), "-6");
Source

pub fn checked_floor(&self) -> Result<Self, RoundDownOverflowError>

Rounds value down after decimal places.

Source

pub fn ceil(&self) -> Self

Rounds value up after decimal places. Panics on overflow.

§Examples
assert_eq!(SignedDecimal::from_str("0.2").unwrap().ceil(), SignedDecimal::one());
assert_eq!(SignedDecimal::from_str("-5.8").unwrap().ceil().to_string(), "-5");
Source

pub fn checked_ceil(&self) -> Result<Self, RoundUpOverflowError>

Rounds value up after decimal places. Returns OverflowError on overflow.

Source

pub fn checked_add(self, other: Self) -> Result<Self, OverflowError>

Computes self + other, returning an OverflowError if an overflow occurred.

Source

pub fn checked_sub(self, other: Self) -> Result<Self, OverflowError>

Computes self - other, returning an OverflowError if an overflow occurred.

Source

pub fn checked_mul(self, other: Self) -> Result<Self, OverflowError>

Multiplies one SignedDecimal by another, returning an OverflowError if an overflow occurred.

Source

pub fn pow(self, exp: u32) -> Self

Raises a value to the power of exp, panics if an overflow occurred.

Source

pub fn checked_pow(self, exp: u32) -> Result<Self, OverflowError>

Raises a value to the power of exp, returning an OverflowError if an overflow occurred.

Source

pub fn checked_div(self, other: Self) -> Result<Self, CheckedFromRatioError>

Source

pub fn checked_rem(self, other: Self) -> Result<Self, DivideByZeroError>

Computes self % other, returning an DivideByZeroError if other == 0.

Source

pub const fn abs_diff(self, other: Self) -> Decimal

Source

pub fn saturating_add(self, other: Self) -> Self

Source

pub fn saturating_sub(self, other: Self) -> Self

Source

pub fn saturating_mul(self, other: Self) -> Self

Source

pub fn saturating_pow(self, exp: u32) -> Self

Source

pub fn to_int_floor(self) -> Int128

Converts this decimal to a signed integer by rounding down to the next integer, e.g. 22.5 becomes 22 and -1.2 becomes -2.

§Examples
use core::str::FromStr;
use cosmwasm_std::{SignedDecimal, Int128};

let d = SignedDecimal::from_str("12.345").unwrap();
assert_eq!(d.to_int_floor(), Int128::new(12));

let d = SignedDecimal::from_str("-12.999").unwrap();
assert_eq!(d.to_int_floor(), Int128::new(-13));

let d = SignedDecimal::from_str("-0.05").unwrap();
assert_eq!(d.to_int_floor(), Int128::new(-1));
Source

pub fn to_int_trunc(self) -> Int128

Converts this decimal to a signed integer by truncating the fractional part, e.g. 22.5 becomes 22.

§Examples
use core::str::FromStr;
use cosmwasm_std::{SignedDecimal, Int128};

let d = SignedDecimal::from_str("12.345").unwrap();
assert_eq!(d.to_int_trunc(), Int128::new(12));

let d = SignedDecimal::from_str("-12.999").unwrap();
assert_eq!(d.to_int_trunc(), Int128::new(-12));

let d = SignedDecimal::from_str("75.0").unwrap();
assert_eq!(d.to_int_trunc(), Int128::new(75));
Source

pub fn to_int_ceil(self) -> Int128

Converts this decimal to a signed integer by rounding up to the next integer, e.g. 22.3 becomes 23 and -1.2 becomes -1.

§Examples
use core::str::FromStr;
use cosmwasm_std::{SignedDecimal, Int128};

let d = SignedDecimal::from_str("12.345").unwrap();
assert_eq!(d.to_int_ceil(), Int128::new(13));

let d = SignedDecimal::from_str("-12.999").unwrap();
assert_eq!(d.to_int_ceil(), Int128::new(-12));

let d = SignedDecimal::from_str("75.0").unwrap();
assert_eq!(d.to_int_ceil(), Int128::new(75));

Trait Implementations§

Source§

impl Add<&SignedDecimal> for &SignedDecimal

Source§

type Output = <SignedDecimal as Add>::Output

The resulting type after applying the + operator.
Source§

fn add( self, other: &SignedDecimal, ) -> <SignedDecimal as Add<SignedDecimal>>::Output

Performs the + operation. Read more
Source§

impl Add<&SignedDecimal> for SignedDecimal

Source§

type Output = <SignedDecimal as Add>::Output

The resulting type after applying the + operator.
Source§

fn add( self, other: &SignedDecimal, ) -> <SignedDecimal as Add<SignedDecimal>>::Output

Performs the + operation. Read more
Source§

impl<'a> Add<SignedDecimal> for &'a SignedDecimal

Source§

type Output = <SignedDecimal as Add>::Output

The resulting type after applying the + operator.
Source§

fn add( self, other: SignedDecimal, ) -> <SignedDecimal as Add<SignedDecimal>>::Output

Performs the + operation. Read more
Source§

impl Add for SignedDecimal

Source§

type Output = SignedDecimal

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl AddAssign<&SignedDecimal> for SignedDecimal

Source§

fn add_assign(&mut self, other: &SignedDecimal)

Performs the += operation. Read more
Source§

impl AddAssign for SignedDecimal

Source§

fn add_assign(&mut self, rhs: SignedDecimal)

Performs the += operation. Read more
Source§

impl Clone for SignedDecimal

Source§

fn clone(&self) -> SignedDecimal

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 SignedDecimal

Source§

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

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

impl Default for SignedDecimal

Source§

fn default() -> SignedDecimal

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

impl<'de> Deserialize<'de> for SignedDecimal

Deserializes as a base64 string

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 SignedDecimal

Source§

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

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

impl Div<&SignedDecimal> for &SignedDecimal

Source§

type Output = <SignedDecimal as Div>::Output

The resulting type after applying the / operator.
Source§

fn div( self, other: &SignedDecimal, ) -> <SignedDecimal as Div<SignedDecimal>>::Output

Performs the / operation. Read more
Source§

impl Div<&SignedDecimal> for SignedDecimal

Source§

type Output = <SignedDecimal as Div>::Output

The resulting type after applying the / operator.
Source§

fn div( self, other: &SignedDecimal, ) -> <SignedDecimal as Div<SignedDecimal>>::Output

Performs the / operation. Read more
Source§

impl Div<Int128> for SignedDecimal

Source§

type Output = SignedDecimal

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<'a> Div<SignedDecimal> for &'a SignedDecimal

Source§

type Output = <SignedDecimal as Div>::Output

The resulting type after applying the / operator.
Source§

fn div( self, other: SignedDecimal, ) -> <SignedDecimal as Div<SignedDecimal>>::Output

Performs the / operation. Read more
Source§

impl Div for SignedDecimal

Source§

type Output = SignedDecimal

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl DivAssign<&SignedDecimal> for SignedDecimal

Source§

fn div_assign(&mut self, other: &SignedDecimal)

Performs the /= operation. Read more
Source§

impl DivAssign<Int128> for SignedDecimal

Source§

fn div_assign(&mut self, rhs: Int128)

Performs the /= operation. Read more
Source§

impl DivAssign for SignedDecimal

Source§

fn div_assign(&mut self, rhs: SignedDecimal)

Performs the /= operation. Read more
Source§

impl Fraction<Int128> for SignedDecimal

Source§

fn inv(&self) -> Option<Self>

Returns the multiplicative inverse 1/d for decimal d.

If d is zero, none is returned.

Source§

fn numerator(&self) -> Int128

Returns the numerator p
Source§

fn denominator(&self) -> Int128

Returns the denominator q
Source§

impl From<SignedDecimal> for SignedDecimal256

Source§

fn from(value: SignedDecimal) -> Self

Converts to this type from the input type.
Source§

impl FromStr for SignedDecimal

Source§

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

Converts the decimal string to a SignedDecimal Possible inputs: “1.23”, “1”, “000012”, “1.123000000”, “-1.12300” Disallowed: “”, “.23”

This never performs any kind of rounding. More than DECIMAL_PLACES fractional digits, even zeros, result in an error.

Source§

type Err = StdError

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

impl JsonSchema for SignedDecimal

Source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(gen: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
Source§

impl Mul<&SignedDecimal> for &SignedDecimal

Source§

type Output = <SignedDecimal as Mul>::Output

The resulting type after applying the * operator.
Source§

fn mul( self, other: &SignedDecimal, ) -> <SignedDecimal as Mul<SignedDecimal>>::Output

Performs the * operation. Read more
Source§

impl Mul<&SignedDecimal> for SignedDecimal

Source§

type Output = <SignedDecimal as Mul>::Output

The resulting type after applying the * operator.
Source§

fn mul( self, other: &SignedDecimal, ) -> <SignedDecimal as Mul<SignedDecimal>>::Output

Performs the * operation. Read more
Source§

impl<'a> Mul<SignedDecimal> for &'a SignedDecimal

Source§

type Output = <SignedDecimal as Mul>::Output

The resulting type after applying the * operator.
Source§

fn mul( self, other: SignedDecimal, ) -> <SignedDecimal as Mul<SignedDecimal>>::Output

Performs the * operation. Read more
Source§

impl Mul for SignedDecimal

Source§

type Output = SignedDecimal

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl MulAssign<&SignedDecimal> for SignedDecimal

Source§

fn mul_assign(&mut self, other: &SignedDecimal)

Performs the *= operation. Read more
Source§

impl MulAssign for SignedDecimal

Source§

fn mul_assign(&mut self, rhs: SignedDecimal)

Performs the *= operation. Read more
Source§

impl Neg for SignedDecimal

Source§

type Output = SignedDecimal

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl Ord for SignedDecimal

Source§

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

Source§

fn eq(&self, rhs: &&SignedDecimal) -> 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<'a> PartialEq<SignedDecimal> for &'a SignedDecimal

Source§

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

Source§

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

Source§

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

Source§

type Output = <SignedDecimal as Rem>::Output

The resulting type after applying the % operator.
Source§

fn rem( self, other: &SignedDecimal, ) -> <SignedDecimal as Rem<SignedDecimal>>::Output

Performs the % operation. Read more
Source§

impl Rem<&SignedDecimal> for SignedDecimal

Source§

type Output = <SignedDecimal as Rem>::Output

The resulting type after applying the % operator.
Source§

fn rem( self, other: &SignedDecimal, ) -> <SignedDecimal as Rem<SignedDecimal>>::Output

Performs the % operation. Read more
Source§

impl<'a> Rem<SignedDecimal> for &'a SignedDecimal

Source§

type Output = <SignedDecimal as Rem>::Output

The resulting type after applying the % operator.
Source§

fn rem( self, other: SignedDecimal, ) -> <SignedDecimal as Rem<SignedDecimal>>::Output

Performs the % operation. Read more
Source§

impl Rem for SignedDecimal

Source§

fn rem(self, rhs: Self) -> Self

§Panics

This operation will panic if rhs is zero

Source§

type Output = SignedDecimal

The resulting type after applying the % operator.
Source§

impl RemAssign<&SignedDecimal> for SignedDecimal

Source§

fn rem_assign(&mut self, other: &SignedDecimal)

Performs the %= operation. Read more
Source§

impl RemAssign for SignedDecimal

Source§

fn rem_assign(&mut self, rhs: SignedDecimal)

Performs the %= operation. Read more
Source§

impl Serialize for SignedDecimal

Serializes as a decimal string

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

Source§

type Output = <SignedDecimal as Sub>::Output

The resulting type after applying the - operator.
Source§

fn sub( self, other: &SignedDecimal, ) -> <SignedDecimal as Sub<SignedDecimal>>::Output

Performs the - operation. Read more
Source§

impl Sub<&SignedDecimal> for SignedDecimal

Source§

type Output = <SignedDecimal as Sub>::Output

The resulting type after applying the - operator.
Source§

fn sub( self, other: &SignedDecimal, ) -> <SignedDecimal as Sub<SignedDecimal>>::Output

Performs the - operation. Read more
Source§

impl<'a> Sub<SignedDecimal> for &'a SignedDecimal

Source§

type Output = <SignedDecimal as Sub>::Output

The resulting type after applying the - operator.
Source§

fn sub( self, other: SignedDecimal, ) -> <SignedDecimal as Sub<SignedDecimal>>::Output

Performs the - operation. Read more
Source§

impl Sub for SignedDecimal

Source§

type Output = SignedDecimal

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl SubAssign<&SignedDecimal> for SignedDecimal

Source§

fn sub_assign(&mut self, other: &SignedDecimal)

Performs the -= operation. Read more
Source§

impl SubAssign for SignedDecimal

Source§

fn sub_assign(&mut self, rhs: SignedDecimal)

Performs the -= operation. Read more
Source§

impl<A> Sum<A> for SignedDecimal
where Self: Add<A, Output = Self>,

Source§

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

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

impl TryFrom<Decimal> for SignedDecimal

Source§

type Error = SignedDecimalRangeExceeded

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

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

Performs the conversion.
Source§

impl TryFrom<Decimal256> for SignedDecimal

Source§

type Error = SignedDecimalRangeExceeded

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

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

Performs the conversion.
Source§

impl TryFrom<Int128> for SignedDecimal

Source§

type Error = SignedDecimalRangeExceeded

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

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

Performs the conversion.
Source§

impl TryFrom<SignedDecimal> for Decimal

Source§

type Error = DecimalRangeExceeded

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

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

Performs the conversion.
Source§

impl TryFrom<SignedDecimal> for Decimal256

Source§

type Error = Decimal256RangeExceeded

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

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

Performs the conversion.
Source§

impl TryFrom<SignedDecimal256> for SignedDecimal

Source§

type Error = SignedDecimalRangeExceeded

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

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

Performs the conversion.
Source§

impl Copy for SignedDecimal

Source§

impl Eq for SignedDecimal

Source§

impl StructuralPartialEq for SignedDecimal

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<U> As for U

Source§

fn as_<T>(self) -> T
where T: CastFrom<U>,

Casts self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. 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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

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

Source§

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

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

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

Source§

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

Checks if this value is equivalent to the given key. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize = _

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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§

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

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

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

Source§

impl<T, Rhs, Output> GroupOps<Rhs, Output> for T
where T: Add<Rhs, Output = Output> + Sub<Rhs, Output = Output> + AddAssign<Rhs> + SubAssign<Rhs>,

Source§

impl<T, Rhs, Output> GroupOpsOwned<Rhs, Output> for T
where T: for<'r> GroupOps<&'r Rhs, Output>,

Source§

impl<T, Rhs> NumAssignOps<Rhs> for T
where T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,

Source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,

Source§

impl<T, Base> RefNum<Base> for T
where T: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base>,

Source§

impl<T, Rhs, Output> ScalarMul<Rhs, Output> for T
where T: Mul<Rhs, Output = Output> + MulAssign<Rhs>,

Source§

impl<T, Rhs, Output> ScalarMulOwned<Rhs, Output> for T
where T: for<'r> ScalarMul<&'r Rhs, Output>,