Struct sqlx::types::Decimal [−]
pub struct Decimal { /* fields omitted */ }
Expand description
Decimal
represents a 128 bit representation of a fixed-precision decimal number.
The finite set of values of type Decimal
are of the form m / 10e,
where m is an integer such that -296 < m < 296, and e is an integer
between 0 and 28 inclusive.
Implementations
impl Decimal
impl Decimal
pub const NEGATIVE_ONE: Decimal
pub const NEGATIVE_ONE: Decimal
A constant representing -1.
pub const ONE_HUNDRED: Decimal
pub const ONE_HUNDRED: Decimal
A constant representing 100.
pub const ONE_THOUSAND: Decimal
pub const ONE_THOUSAND: Decimal
A constant representing 1000.
Returns a Decimal
with a 64 bit m
representation and corresponding e
scale.
Arguments
num
- An i64 that represents them
portion of the decimal numberscale
- A u32 representing thee
portion of the decimal number.
Panics
This function panics if scale
is > 28.
Example
use rust_decimal::Decimal;
let pi = Decimal::new(3141, 3);
assert_eq!(pi.to_string(), "3.141");
Checked version of Decimal::new
. Will return Err
instead of panicking at run-time.
Example
use rust_decimal::Decimal;
let max = Decimal::try_new(i64::MAX, u32::MAX);
assert!(max.is_err());
pub fn from_i128_with_scale(num: i128, scale: u32) -> Decimal
pub fn from_i128_with_scale(num: i128, scale: u32) -> Decimal
Creates a Decimal
using a 128 bit signed m
representation and corresponding e
scale.
Arguments
num
- An i128 that represents them
portion of the decimal numberscale
- A u32 representing thee
portion of the decimal number.
Panics
This function panics if scale
is > 28 or if num
exceeds the maximum supported 96 bits.
Example
use rust_decimal::Decimal;
let pi = Decimal::from_i128_with_scale(3141i128, 3);
assert_eq!(pi.to_string(), "3.141");
pub const fn try_from_i128_with_scale(
num: i128,
scale: u32
) -> Result<Decimal, Error>
pub const fn try_from_i128_with_scale(
num: i128,
scale: u32
) -> Result<Decimal, Error>
Checked version of Decimal::from_i128_with_scale
. Will return Err
instead
of panicking at run-time.
Example
use rust_decimal::Decimal;
let max = Decimal::try_from_i128_with_scale(i128::MAX, u32::MAX);
assert!(max.is_err());
Returns a Decimal
using the instances constituent parts.
Arguments
lo
- The low 32 bits of a 96-bit integer.mid
- The middle 32 bits of a 96-bit integer.hi
- The high 32 bits of a 96-bit integer.negative
-true
to indicate a negative number.scale
- A power of 10 ranging from 0 to 28.
Caution: Undefined behavior
While a scale greater than 28 can be passed in, it will be automatically capped by this function at the maximum precision. The library opts towards this functionality as opposed to a panic to ensure that the function can be treated as constant. This may lead to undefined behavior in downstream applications and should be treated with caution.
Example
use rust_decimal::Decimal;
let pi = Decimal::from_parts(1102470952, 185874565, 1703060790, false, 28);
assert_eq!(pi.to_string(), "3.1415926535897932384626433832");
pub fn from_scientific(value: &str) -> Result<Decimal, Error>
pub fn from_scientific(value: &str) -> Result<Decimal, Error>
Returns a Result
which if successful contains the Decimal
constitution of
the scientific notation provided by value
.
Arguments
value
- The scientific notation of theDecimal
.
Example
use rust_decimal::Decimal;
let value = Decimal::from_scientific("9.7e-7").unwrap();
assert_eq!(value.to_string(), "0.00000097");
Returns the scale of the decimal number, otherwise known as e
.
Example
use rust_decimal::Decimal;
let num = Decimal::new(1234, 3);
assert_eq!(num.scale(), 3u32);
Returns the mantissa of the decimal number.
Example
use rust_decimal::prelude::*;
let num = Decimal::from_str("-1.2345678").unwrap();
assert_eq!(num.mantissa(), -12345678i128);
assert_eq!(num.scale(), 7);
Returns true if this Decimal number is equivalent to zero.
Example
use rust_decimal::prelude::*;
let num = Decimal::ZERO;
assert!(num.is_zero());
👎 Deprecated since 1.4.0: please use set_sign_positive
instead
please use set_sign_positive
instead
pub fn set_sign_positive(&mut self, positive: bool)
pub fn set_sign_positive(&mut self, positive: bool)
pub fn set_sign_negative(&mut self, negative: bool)
pub fn set_sign_negative(&mut self, negative: bool)
Modifies the Decimal
to the given scale, attempting to do so without changing the
underlying number itself.
Note that setting the scale to something less then the current Decimal
s scale will
cause the newly created Decimal
to have some rounding.
Scales greater than the maximum precision supported by Decimal
will be automatically
rounded to Decimal::MAX_PRECISION
.
Rounding leverages the half up strategy.
Arguments
scale
: The scale to use for the newDecimal
number.
Example
use rust_decimal::prelude::*;
// Rescaling to a higher scale preserves the value
let mut number = Decimal::from_str("1.123").unwrap();
assert_eq!(number.scale(), 3);
number.rescale(6);
assert_eq!(number.to_string(), "1.123000");
assert_eq!(number.scale(), 6);
// Rescaling to a lower scale forces the number to be rounded
let mut number = Decimal::from_str("1.45").unwrap();
assert_eq!(number.scale(), 2);
number.rescale(1);
assert_eq!(number.to_string(), "1.5");
assert_eq!(number.scale(), 1);
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 const fn deserialize(bytes: [u8; 16]) -> Decimal
pub const fn deserialize(bytes: [u8; 16]) -> Decimal
Deserializes the given bytes into a decimal number. The deserialized byte representation must be 16 bytes and adhere to the following convention:
- 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
pub fn is_negative(&self) -> bool
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
pub fn is_positive(&self) -> bool
please use is_sign_positive
instead
Returns true
if the decimal is positive.
pub const fn is_sign_negative(&self) -> bool
pub const fn is_sign_negative(&self) -> bool
Returns true
if the sign bit of the decimal is negative.
pub const fn is_sign_positive(&self) -> bool
pub const fn is_sign_positive(&self) -> bool
Returns true
if the sign bit of the decimal is positive.
👎 Deprecated since 1.12.0: Use the associated constant Decimal::MIN
Use the associated constant Decimal::MIN
Returns the minimum possible number that Decimal
can represent.
👎 Deprecated since 1.12.0: Use the associated constant Decimal::MAX
Use the associated constant Decimal::MAX
Returns the maximum possible number that Decimal
can represent.
Returns a new Decimal
integral with no fractional portion.
This is a true truncation whereby no rounding is performed.
Example
use rust_decimal::Decimal;
let pi = Decimal::new(3141, 3);
let trunc = Decimal::new(3, 0);
// note that it returns a decimal
assert_eq!(pi.trunc(), trunc);
Returns a new Decimal
representing the fractional portion of the number.
Example
use rust_decimal::Decimal;
let pi = Decimal::new(3141, 3);
let fract = Decimal::new(141, 3);
// note that it returns a decimal
assert_eq!(pi.fract(), fract);
Computes the absolute value of self
.
Example
use rust_decimal::Decimal;
let num = Decimal::new(-3141, 3);
assert_eq!(num.abs().to_string(), "3.141");
Returns the largest integer less than or equal to a number.
Example
use rust_decimal::Decimal;
let num = Decimal::new(3641, 3);
assert_eq!(num.floor().to_string(), "3");
Returns the smallest integer greater than or equal to a number.
Example
use rust_decimal::Decimal;
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");
Returns the maximum of the two numbers.
use rust_decimal::Decimal;
let x = Decimal::new(1, 0);
let y = Decimal::new(2, 0);
assert_eq!(y, x.max(y));
Returns the minimum of the two numbers.
use rust_decimal::Decimal;
let x = Decimal::new(1, 0);
let y = Decimal::new(2, 0);
assert_eq!(x, x.min(y));
Strips any trailing zero’s from a Decimal
and converts -0 to 0.
Example
use rust_decimal::prelude::*;
let number = Decimal::from_str("3.100").unwrap();
assert_eq!(number.normalize().to_string(), "3.1");
pub fn normalize_assign(&mut self)
pub fn normalize_assign(&mut self)
An in place version of normalize
. Strips any trailing zero’s from a Decimal
and converts -0 to 0.
Example
use rust_decimal::prelude::*;
let mut number = Decimal::from_str("3.100").unwrap();
assert_eq!(number.to_string(), "3.100");
number.normalize_assign();
assert_eq!(number.to_string(), "3.1");
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
use rust_decimal::Decimal;
// 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
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
use rust_decimal::{Decimal, RoundingStrategy};
use core::str::FromStr;
let tax = Decimal::from_str("3.4395").unwrap();
assert_eq!(tax.round_dp_with_strategy(2, RoundingStrategy::MidpointAwayFromZero).to_string(), "3.44");
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
use rust_decimal::Decimal;
use core::str::FromStr;
let pi = Decimal::from_str("3.1415926535897932384626433832").unwrap();
assert_eq!(pi.round_dp(2).to_string(), "3.14");
pub const fn unpack(&self) -> UnpackedDecimal
pub const 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
use rust_decimal::Decimal;
use core::str::FromStr;
let pi = Decimal::from_str("3.1415926535897932384626433832").unwrap();
assert_eq!(format!("{:?}", pi), "3.1415926535897932384626433832");
assert_eq!(format!("{:?}", pi.unpack()), "UnpackedDecimal { \
negative: false, scale: 28, hi: 1703060790, mid: 185874565, lo: 1102470952 \
}");
pub fn checked_add(self, other: Decimal) -> Option<Decimal>
pub fn checked_add(self, other: Decimal) -> Option<Decimal>
Checked addition. Computes self + other
, returning None
if overflow occurred.
pub fn checked_sub(self, other: Decimal) -> Option<Decimal>
pub fn checked_sub(self, other: Decimal) -> Option<Decimal>
Checked subtraction. Computes self - other
, returning None
if overflow occurred.
pub fn checked_mul(self, other: Decimal) -> Option<Decimal>
pub fn checked_mul(self, other: Decimal) -> Option<Decimal>
Checked multiplication. Computes self * other
, returning None
if overflow occurred.
pub fn checked_div(self, other: Decimal) -> Option<Decimal>
pub fn checked_div(self, other: Decimal) -> Option<Decimal>
Checked division. Computes self / other
, returning None
if other == 0.0
or the
division results in overflow.
pub fn checked_rem(self, other: Decimal) -> Option<Decimal>
pub fn checked_rem(self, other: Decimal) -> Option<Decimal>
Checked remainder. Computes self % other
, returning None
if other == 0.0
.
pub fn from_str_radix(str: &str, radix: u32) -> Result<Decimal, Error>
Trait Implementations
pub fn add_assign(&mut self, other: &'a Decimal)
pub fn add_assign(&mut self, other: &'a Decimal)
Performs the +=
operation. Read more
pub fn add_assign(&mut self, other: &'a Decimal)
pub fn add_assign(&mut self, other: &'a Decimal)
Performs the +=
operation. Read more
pub fn add_assign(&mut self, other: Decimal)
pub fn add_assign(&mut self, other: Decimal)
Performs the +=
operation. Read more
pub fn add_assign(&mut self, other: Decimal)
pub fn add_assign(&mut self, other: Decimal)
Performs the +=
operation. Read more
impl CheckedAdd for Decimal
impl CheckedAdd for Decimal
pub fn checked_add(&self, v: &Decimal) -> Option<Decimal>
pub fn checked_add(&self, v: &Decimal) -> Option<Decimal>
Adds two numbers, checking for overflow. If overflow happens, None
is
returned. Read more
impl CheckedDiv for Decimal
impl CheckedDiv for Decimal
pub fn checked_div(&self, v: &Decimal) -> Option<Decimal>
pub fn checked_div(&self, v: &Decimal) -> Option<Decimal>
Divides two numbers, checking for underflow, overflow and division by
zero. If any of that happens, None
is returned. Read more
impl CheckedMul for Decimal
impl CheckedMul for Decimal
pub fn checked_mul(&self, v: &Decimal) -> Option<Decimal>
pub fn checked_mul(&self, v: &Decimal) -> Option<Decimal>
Multiplies two numbers, checking for underflow or overflow. If underflow
or overflow happens, None
is returned. Read more
impl CheckedRem for Decimal
impl CheckedRem for Decimal
pub fn checked_rem(&self, v: &Decimal) -> Option<Decimal>
pub fn checked_rem(&self, v: &Decimal) -> Option<Decimal>
Finds the remainder of dividing two numbers, checking for underflow, overflow and division
by zero. If any of that happens, None
is returned. Read more
impl CheckedSub for Decimal
impl CheckedSub for Decimal
pub fn checked_sub(&self, v: &Decimal) -> Option<Decimal>
pub fn checked_sub(&self, v: &Decimal) -> Option<Decimal>
Subtracts two numbers, checking for underflow. If underflow happens,
None
is returned. Read more
impl<'de> Deserialize<'de> for Decimal
impl<'de> Deserialize<'de> for Decimal
pub fn deserialize<D>(
deserializer: D
) -> Result<Decimal, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
pub fn deserialize<D>(
deserializer: D
) -> Result<Decimal, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
pub fn div_assign(&mut self, other: &'a Decimal)
pub fn div_assign(&mut self, other: &'a Decimal)
Performs the /=
operation. Read more
pub fn div_assign(&mut self, other: &'a Decimal)
pub fn div_assign(&mut self, other: &'a Decimal)
Performs the /=
operation. Read more
pub fn div_assign(&mut self, other: Decimal)
pub fn div_assign(&mut self, other: Decimal)
Performs the /=
operation. Read more
pub fn div_assign(&mut self, other: Decimal)
pub fn div_assign(&mut self, other: Decimal)
Performs the /=
operation. Read more
Writes the value of self
into buf
without moving self
. Read more
Writes the value of self
into buf
in the expected format for the database.
Panics
If this Decimal
cannot be represented by PgNumeric
.
Writes the value of self
into buf
without moving self
. Read more
Writes the value of self
into buf
in the expected format for the database.
impl FromPrimitive for Decimal
impl FromPrimitive for Decimal
Converts an i32
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read more
Converts an i64
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read more
Converts an i128
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read more
Converts an u32
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read more
Converts an u64
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read more
Converts an u128
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read more
Converts a f32
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read more
Converts a f64
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read more
Converts an isize
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read more
Converts an i8
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read more
Converts an i16
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read more
Converts a usize
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read more
Converts an u8
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read more
pub fn mul_assign(&mut self, other: &'a Decimal)
pub fn mul_assign(&mut self, other: &'a Decimal)
Performs the *=
operation. Read more
pub fn mul_assign(&mut self, other: &'a Decimal)
pub fn mul_assign(&mut self, other: &'a Decimal)
Performs the *=
operation. Read more
pub fn mul_assign(&mut self, other: Decimal)
pub fn mul_assign(&mut self, other: Decimal)
Performs the *=
operation. Read more
pub fn mul_assign(&mut self, other: Decimal)
pub fn mul_assign(&mut self, other: Decimal)
Performs the *=
operation. Read more
type FromStrRadixErr = Error
pub fn from_str_radix(
str: &str,
radix: u32
) -> Result<Decimal, <Decimal as Num>::FromStrRadixErr>
pub fn from_str_radix(
str: &str,
radix: u32
) -> Result<Decimal, <Decimal as Num>::FromStrRadixErr>
Convert from a string and radix (typically 2..=36
). Read more
impl PartialOrd<Decimal> for Decimal
impl PartialOrd<Decimal> for Decimal
pub fn partial_cmp(&self, other: &Decimal) -> Option<Ordering>
pub fn partial_cmp(&self, other: &Decimal) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
pub fn rem_assign(&mut self, other: &'a Decimal)
pub fn rem_assign(&mut self, other: &'a Decimal)
Performs the %=
operation. Read more
pub fn rem_assign(&mut self, other: &'a Decimal)
pub fn rem_assign(&mut self, other: &'a Decimal)
Performs the %=
operation. Read more
pub fn rem_assign(&mut self, other: Decimal)
pub fn rem_assign(&mut self, other: Decimal)
Performs the %=
operation. Read more
pub fn rem_assign(&mut self, other: Decimal)
pub fn rem_assign(&mut self, other: Decimal)
Performs the %=
operation. Read more
pub fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
pub fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
pub fn is_positive(&self) -> bool
pub fn is_positive(&self) -> bool
Returns true if the number is positive and false if the number is zero or negative.
pub fn is_negative(&self) -> bool
pub fn is_negative(&self) -> bool
Returns true if the number is negative and false if the number is zero or positive.
pub fn sub_assign(&mut self, other: &'a Decimal)
pub fn sub_assign(&mut self, other: &'a Decimal)
Performs the -=
operation. Read more
pub fn sub_assign(&mut self, other: &'a Decimal)
pub fn sub_assign(&mut self, other: &'a Decimal)
Performs the -=
operation. Read more
pub fn sub_assign(&mut self, other: Decimal)
pub fn sub_assign(&mut self, other: Decimal)
Performs the -=
operation. Read more
pub fn sub_assign(&mut self, other: Decimal)
pub fn sub_assign(&mut self, other: Decimal)
Performs the -=
operation. Read more
impl ToPrimitive for Decimal
impl ToPrimitive for Decimal
Converts the value of self
to an i64
. If the value cannot be
represented by an i64
, then None
is returned. Read more
Converts the value of self
to an i128
. If the value cannot be
represented by an i128
(i64
under the default implementation), then
None
is returned. Read more
Converts the value of self
to a u64
. If the value cannot be
represented by a u64
, then None
is returned. Read more
Converts the value of self
to a u128
. If the value cannot be
represented by a u128
(u64
under the default implementation), then
None
is returned. Read more
Converts the value of self
to an f64
. Overflows may map to positive
or negative inifinity, otherwise None
is returned if the value cannot
be represented by an f64
. Read more
Converts the value of self
to an isize
. If the value cannot be
represented by an isize
, then None
is returned. Read more
Converts the value of self
to an i8
. If the value cannot be
represented by an i8
, then None
is returned. Read more
Converts the value of self
to an i16
. If the value cannot be
represented by an i16
, then None
is returned. Read more
Converts the value of self
to an i32
. If the value cannot be
represented by an i32
, then None
is returned. Read more
Converts the value of self
to a usize
. If the value cannot be
represented by a usize
, then None
is returned. Read more
Converts the value of self
to a u8
. If the value cannot be
represented by a u8
, then None
is returned. Read more
Converts the value of self
to a u16
. If the value cannot be
represented by a u16
, then None
is returned. Read more
Converts the value of self
to a u32
. If the value cannot be
represented by a u32
, then None
is returned. Read more
Returns the canonical SQL type for this Rust type. Read more
Returns the canonical SQL type for this Rust type. Read more
Auto Trait Implementations
impl RefUnwindSafe for Decimal
impl UnwindSafe for Decimal
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.
fn fmt_binary(self) -> FmtBinary<Self> where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self> where
Self: Binary,
Causes self
to use its Binary
implementation when Debug
-formatted.
fn fmt_display(self) -> FmtDisplay<Self> where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self> where
Self: Display,
Causes self
to use its Display
implementation when
Debug
-formatted. Read more
fn fmt_lower_exp(self) -> FmtLowerExp<Self> where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self> where
Self: LowerExp,
Causes self
to use its LowerExp
implementation when
Debug
-formatted. Read more
fn fmt_lower_hex(self) -> FmtLowerHex<Self> where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self> where
Self: LowerHex,
Causes self
to use its LowerHex
implementation when
Debug
-formatted. Read more
Causes self
to use its Octal
implementation when Debug
-formatted.
fn fmt_pointer(self) -> FmtPointer<Self> where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self> where
Self: Pointer,
Causes self
to use its Pointer
implementation when
Debug
-formatted. Read more
fn fmt_upper_exp(self) -> FmtUpperExp<Self> where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self> where
Self: UpperExp,
Causes self
to use its UpperExp
implementation when
Debug
-formatted. Read more
fn fmt_upper_hex(self) -> FmtUpperHex<Self> where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self> where
Self: UpperHex,
Causes self
to use its UpperHex
implementation when
Debug
-formatted. Read more
impl<T> Pipe for T where
T: ?Sized,
impl<T> Pipe for T where
T: ?Sized,
Pipes by value. This is generally the method you want to use. Read more
Borrows self
and passes that borrow into the pipe function. Read more
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R where
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R where
R: 'a,
Mutably borrows self
and passes that borrow into the pipe function. Read more
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R where
Self: Borrow<B>,
R: 'a,
B: 'a + ?Sized,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R where
Self: Borrow<B>,
R: 'a,
B: 'a + ?Sized,
Borrows self
, then passes self.borrow()
into the pipe function. Read more
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R where
Self: BorrowMut<B>,
R: 'a,
B: 'a + ?Sized,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R where
Self: BorrowMut<B>,
R: 'a,
B: 'a + ?Sized,
Mutably borrows self
, then passes self.borrow_mut()
into the pipe
function. Read more
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R where
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R where
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
Borrows self
, then passes self.as_ref()
into the pipe function.
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R where
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R where
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
Mutably borrows self
, then passes self.as_mut()
into the pipe
function. Read more
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: Deref<Target = T>,
T: 'a + ?Sized,
R: 'a,
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: Deref<Target = T>,
T: 'a + ?Sized,
R: 'a,
Borrows self
, then passes self.deref()
into the pipe function.
fn pipe_as_ref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: AsRef<T>,
T: 'a,
R: 'a,
fn pipe_as_ref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: AsRef<T>,
T: 'a,
R: 'a,
Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more
fn pipe_as_mut<'a, T, R>(&'a mut self, func: impl FnOnce(&'a mut T) -> R) -> R where
Self: AsMut<T>,
T: 'a,
R: 'a,
fn pipe_as_mut<'a, T, R>(&'a mut self, func: impl FnOnce(&'a mut T) -> R) -> R where
Self: AsMut<T>,
T: 'a,
R: 'a,
Pipes a trait mutable borrow into a function that cannot normally be called in suffix position. Read more
fn pipe_borrow<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: Borrow<T>,
T: 'a,
R: 'a,
fn pipe_borrow<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: Borrow<T>,
T: 'a,
R: 'a,
Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more
fn pipe_borrow_mut<'a, T, R>(
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
Self: BorrowMut<T>,
T: 'a,
R: 'a,
fn pipe_borrow_mut<'a, T, R>(
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
Self: BorrowMut<T>,
T: 'a,
R: 'a,
Pipes a trait mutable borrow into a function that cannot normally be called in suffix position. Read more
fn pipe_deref<'a, R>(&'a self, func: impl FnOnce(&'a Self::Target) -> R) -> R where
Self: Deref,
R: 'a,
fn pipe_deref<'a, R>(&'a self, func: impl FnOnce(&'a Self::Target) -> R) -> R where
Self: Deref,
R: 'a,
Pipes a dereference into a function that cannot normally be called in suffix position. Read more
fn pipe_deref_mut<'a, R>(
&'a mut self,
func: impl FnOnce(&'a mut Self::Target) -> R
) -> R where
Self: DerefMut,
R: 'a,
fn pipe_deref_mut<'a, R>(
&'a mut self,
func: impl FnOnce(&'a mut Self::Target) -> R
) -> R where
Self: DerefMut,
R: 'a,
Pipes a mutable dereference into a function that cannot normally be called in suffix position. Read more
Pipes a reference into a function that cannot ordinarily be called in suffix position. Read more
type Output = T
type Output = T
Should always be Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self where
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self where
Self: Borrow<B>,
B: ?Sized,
Immutable access to the Borrow<B>
of a value. Read more
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self where
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self where
Self: BorrowMut<B>,
B: ?Sized,
Mutable access to the BorrowMut<B>
of a value. Read more
Immutable access to the AsRef<R>
view of a value. Read more
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self where
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self where
Self: AsMut<R>,
R: ?Sized,
Mutable access to the AsMut<R>
view of a value. Read more
Immutable access to the Deref::Target
of a value. Read more
Mutable access to the Deref::Target
of a value. Read more
Calls .tap()
only in debug builds, and is erased in release builds.
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls .tap_mut()
only in debug builds, and is erased in release
builds. Read more
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self where
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self where
Self: Borrow<B>,
B: ?Sized,
Calls .tap_borrow()
only in debug builds, and is erased in release
builds. Read more
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self where
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self where
Self: BorrowMut<B>,
B: ?Sized,
Calls .tap_borrow_mut()
only in debug builds, and is erased in release
builds. Read more
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self where
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self where
Self: AsRef<R>,
R: ?Sized,
Calls .tap_ref()
only in debug builds, and is erased in release
builds. Read more
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self where
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self where
Self: AsMut<R>,
R: ?Sized,
Calls .tap_ref_mut()
only in debug builds, and is erased in release
builds. Read more
Provides immutable access for inspection. Read more
Calls tap
in debug builds, and does nothing in release builds.
Provides mutable access for modification. Read more
fn tap_mut_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self) -> R,
fn tap_mut_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self) -> R,
Calls tap_mut
in debug builds, and does nothing in release builds.
impl<T, U> TapAsRef<U> for T where
U: ?Sized,
impl<T, U> TapAsRef<U> for T where
U: ?Sized,
Provides immutable access to the reference for inspection.
fn tap_ref_dbg<F, R>(self, func: F) -> Self where
Self: AsRef<T>,
F: FnOnce(&T) -> R,
fn tap_ref_dbg<F, R>(self, func: F) -> Self where
Self: AsRef<T>,
F: FnOnce(&T) -> R,
Calls tap_ref
in debug builds, and does nothing in release builds.
fn tap_ref_mut<F, R>(self, func: F) -> Self where
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
fn tap_ref_mut<F, R>(self, func: F) -> Self where
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
Provides mutable access to the reference for modification.
fn tap_ref_mut_dbg<F, R>(self, func: F) -> Self where
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
fn tap_ref_mut_dbg<F, R>(self, func: F) -> Self where
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
Calls tap_ref_mut
in debug builds, and does nothing in release builds.
impl<T, U> TapBorrow<U> for T where
U: ?Sized,
impl<T, U> TapBorrow<U> for T where
U: ?Sized,
fn tap_borrow<F, R>(self, func: F) -> Self where
Self: Borrow<T>,
F: FnOnce(&T) -> R,
fn tap_borrow<F, R>(self, func: F) -> Self where
Self: Borrow<T>,
F: FnOnce(&T) -> R,
Provides immutable access to the borrow for inspection. Read more
fn tap_borrow_dbg<F, R>(self, func: F) -> Self where
Self: Borrow<T>,
F: FnOnce(&T) -> R,
fn tap_borrow_dbg<F, R>(self, func: F) -> Self where
Self: Borrow<T>,
F: FnOnce(&T) -> R,
Calls tap_borrow
in debug builds, and does nothing in release builds.
fn tap_borrow_mut<F, R>(self, func: F) -> Self where
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
fn tap_borrow_mut<F, R>(self, func: F) -> Self where
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
Provides mutable access to the borrow for modification.
fn tap_borrow_mut_dbg<F, R>(self, func: F) -> Self where
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
fn tap_borrow_mut_dbg<F, R>(self, func: F) -> Self where
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
Calls tap_borrow_mut
in debug builds, and does nothing in release
builds. Read more
Immutably dereferences self
for inspection.
fn tap_deref_dbg<F, R>(self, func: F) -> Self where
Self: Deref,
F: FnOnce(&Self::Target) -> R,
fn tap_deref_dbg<F, R>(self, func: F) -> Self where
Self: Deref,
F: FnOnce(&Self::Target) -> R,
Calls tap_deref
in debug builds, and does nothing in release builds.
fn tap_deref_mut<F, R>(self, func: F) -> Self where
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
fn tap_deref_mut<F, R>(self, func: F) -> Self where
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
Mutably dereferences self
for modification.
fn tap_deref_mut_dbg<F, R>(self, func: F) -> Self where
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
fn tap_deref_mut_dbg<F, R>(self, func: F) -> Self where
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
Calls tap_deref_mut
in debug builds, and does nothing in release
builds. Read more