pub struct Scalar(_);arithmetic only.Expand description
Scalars are elements in the finite field modulo n.
Trait impls
Much of the important functionality of scalars is provided by traits from
the ff crate, which is re-exported as
p256::elliptic_curve::ff:
Field- represents elements of finite fields and provides:Field::random- generate a random scalardouble,square, andinvertoperations- Bounds for
Add,Sub,Mul, andNeg(as well as*Assignequivalents) - Bounds for
ConditionallySelectablefrom thesubtlecrate
PrimeField- represents elements of prime fields and provides:from_repr/to_reprfor converting field elements from/to big integers.multiplicative_generatorandroot_of_unityconstants.
PrimeFieldBits- operations over field elements represented as bits (requiresbitsfeature)
Please see the documentation for the relevant traits for more information.
serde support
When the serde feature of this crate is enabled, the Serialize and
Deserialize traits are impl’d for this type.
The serialization is a fixed-width big endian encoding. When used with textual formats, the binary data is encoded as hexadecimal.
Implementations
sourceimpl Scalar
impl Scalar
sourcepub fn to_bytes(&self) -> FieldBytes
pub fn to_bytes(&self) -> FieldBytes
Returns the SEC1 encoding of this scalar.
sourcepub fn invert(&self) -> CtOption<Self>
pub fn invert(&self) -> CtOption<Self>
Returns the multiplicative inverse of self, if self is non-zero
sourcepub fn invert_vartime(&self) -> CtOption<Self>
pub fn invert_vartime(&self) -> CtOption<Self>
Faster inversion using Stein’s algorithm
Trait Implementations
sourceimpl AddAssign<&'_ Scalar> for Scalar
impl AddAssign<&'_ Scalar> for Scalar
sourcefn add_assign(&mut self, rhs: &Scalar)
fn add_assign(&mut self, rhs: &Scalar)
Performs the += operation. Read more
sourceimpl AddAssign<Scalar> for Scalar
impl AddAssign<Scalar> for Scalar
sourcefn add_assign(&mut self, rhs: Scalar)
fn add_assign(&mut self, rhs: Scalar)
Performs the += operation. Read more
sourceimpl Borrow<Scalar> for BlindedScalar
impl Borrow<Scalar> for BlindedScalar
sourceimpl ConditionallySelectable for Scalar
impl ConditionallySelectable for Scalar
sourceimpl ConstantTimeEq for Scalar
impl ConstantTimeEq for Scalar
sourceimpl<'de> Deserialize<'de> for Scalar
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Scalar
serde only.sourcefn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Field for Scalar
impl Field for Scalar
sourcefn sqrt(&self) -> CtOption<Self>
fn sqrt(&self) -> CtOption<Self>
Tonelli-Shank’s algorithm for q mod 16 = 1 https://eprint.iacr.org/2012/685.pdf (page 12, algorithm 5)
sourcefn random(rng: impl RngCore) -> Self
fn random(rng: impl RngCore) -> Self
Returns an element chosen uniformly at random using a user-provided RNG.
sourcefn invert(&self) -> CtOption<Self>
fn invert(&self) -> CtOption<Self>
Computes the multiplicative inverse of this element, failing if the element is zero. Read more
fn is_zero_vartime(&self) -> bool
fn is_zero_vartime(&self) -> bool
Returns true iff this element is zero. Read more
fn cube(&self) -> Self
fn cube(&self) -> Self
Cubes this element.
sourceimpl From<&'_ Scalar> for FieldBytes
impl From<&'_ Scalar> for FieldBytes
sourceimpl From<&'_ Scalar> for ScalarCore<NistP256>
impl From<&'_ Scalar> for ScalarCore<NistP256>
sourcefn from(scalar: &Scalar) -> ScalarCore<NistP256>
fn from(scalar: &Scalar) -> ScalarCore<NistP256>
Converts to this type from the input type.
sourceimpl From<&'_ Scalar> for ScalarBits
Available on crate feature bits only.
impl From<&'_ Scalar> for ScalarBits
bits only.sourcefn from(scalar: &Scalar) -> ScalarBits
fn from(scalar: &Scalar) -> ScalarBits
Converts to this type from the input type.
sourceimpl From<&'_ ScalarCore<NistP256>> for Scalar
impl From<&'_ ScalarCore<NistP256>> for Scalar
sourcefn from(scalar: &ScalarCore<NistP256>) -> Scalar
fn from(scalar: &ScalarCore<NistP256>) -> Scalar
Converts to this type from the input type.
sourceimpl From<Scalar> for FieldBytes
impl From<Scalar> for FieldBytes
sourceimpl From<Scalar> for ScalarCore<NistP256>
impl From<Scalar> for ScalarCore<NistP256>
sourcefn from(scalar: Scalar) -> ScalarCore<NistP256>
fn from(scalar: Scalar) -> ScalarCore<NistP256>
Converts to this type from the input type.
sourceimpl From<ScalarCore<NistP256>> for Scalar
impl From<ScalarCore<NistP256>> for Scalar
sourcefn from(scalar: ScalarCore<NistP256>) -> Scalar
fn from(scalar: ScalarCore<NistP256>) -> Scalar
Converts to this type from the input type.
sourceimpl Mul<&'_ Scalar> for AffinePoint
impl Mul<&'_ Scalar> for AffinePoint
type Output = ProjectivePoint
type Output = ProjectivePoint
The resulting type after applying the * operator.
sourcefn mul(self, scalar: &Scalar) -> ProjectivePoint
fn mul(self, scalar: &Scalar) -> ProjectivePoint
Performs the * operation. Read more
sourceimpl Mul<&'_ Scalar> for &ProjectivePoint
impl Mul<&'_ Scalar> for &ProjectivePoint
type Output = ProjectivePoint
type Output = ProjectivePoint
The resulting type after applying the * operator.
sourcefn mul(self, other: &Scalar) -> ProjectivePoint
fn mul(self, other: &Scalar) -> ProjectivePoint
Performs the * operation. Read more
sourceimpl Mul<&'_ Scalar> for ProjectivePoint
impl Mul<&'_ Scalar> for ProjectivePoint
type Output = ProjectivePoint
type Output = ProjectivePoint
The resulting type after applying the * operator.
sourcefn mul(self, other: &Scalar) -> ProjectivePoint
fn mul(self, other: &Scalar) -> ProjectivePoint
Performs the * operation. Read more
sourceimpl Mul<Scalar> for AffinePoint
impl Mul<Scalar> for AffinePoint
type Output = ProjectivePoint
type Output = ProjectivePoint
The resulting type after applying the * operator.
sourcefn mul(self, scalar: Scalar) -> ProjectivePoint
fn mul(self, scalar: Scalar) -> ProjectivePoint
Performs the * operation. Read more
sourceimpl Mul<Scalar> for ProjectivePoint
impl Mul<Scalar> for ProjectivePoint
type Output = ProjectivePoint
type Output = ProjectivePoint
The resulting type after applying the * operator.
sourcefn mul(self, other: Scalar) -> ProjectivePoint
fn mul(self, other: Scalar) -> ProjectivePoint
Performs the * operation. Read more
sourceimpl MulAssign<&'_ Scalar> for ProjectivePoint
impl MulAssign<&'_ Scalar> for ProjectivePoint
sourcefn mul_assign(&mut self, rhs: &Scalar)
fn mul_assign(&mut self, rhs: &Scalar)
Performs the *= operation. Read more
sourceimpl MulAssign<&'_ Scalar> for Scalar
impl MulAssign<&'_ Scalar> for Scalar
sourcefn mul_assign(&mut self, rhs: &Scalar)
fn mul_assign(&mut self, rhs: &Scalar)
Performs the *= operation. Read more
sourceimpl MulAssign<Scalar> for ProjectivePoint
impl MulAssign<Scalar> for ProjectivePoint
sourcefn mul_assign(&mut self, rhs: Scalar)
fn mul_assign(&mut self, rhs: Scalar)
Performs the *= operation. Read more
sourceimpl MulAssign<Scalar> for Scalar
impl MulAssign<Scalar> for Scalar
sourcefn mul_assign(&mut self, rhs: Scalar)
fn mul_assign(&mut self, rhs: Scalar)
Performs the *= operation. Read more
sourceimpl Ord for Scalar
impl Ord for Scalar
sourceimpl PartialOrd<Scalar> for Scalar
impl PartialOrd<Scalar> for Scalar
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self and other values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
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 · sourcefn le(&self, other: &Rhs) -> bool
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
sourceimpl PrimeField for Scalar
impl PrimeField for Scalar
sourcefn from_repr(bytes: FieldBytes) -> CtOption<Self>
fn from_repr(bytes: FieldBytes) -> CtOption<Self>
Attempts to parse the given byte array as an SEC1-encoded scalar.
Returns None if the byte array does not contain a big-endian integer in the range [0, p).
type Repr = GenericArray<u8, <<NistP256 as Curve>::UInt as ArrayEncoding>::ByteSize>
type Repr = GenericArray<u8, <<NistP256 as Curve>::UInt as ArrayEncoding>::ByteSize>
The prime field can be converted back and forth into this binary representation. Read more
sourceconst CAPACITY: u32 = 255u32
const CAPACITY: u32 = 255u32
How many bits of information can be reliably stored in the field element. Read more
sourceconst S: u32 = 4u32
const S: u32 = 4u32
An integer s satisfying the equation 2^s * t = modulus - 1 with t odd. Read more
sourcefn to_repr(&self) -> FieldBytes
fn to_repr(&self) -> FieldBytes
Converts an element of the prime field into the standard byte representation for this field. Read more
sourcefn multiplicative_generator() -> Self
fn multiplicative_generator() -> Self
Returns a fixed multiplicative generator of modulus - 1 order. This element must
also be a quadratic nonresidue. Read more
sourcefn root_of_unity() -> Self
fn root_of_unity() -> Self
Returns the 2^s root of unity. Read more
fn from_str_vartime(s: &str) -> Option<Self>
fn from_str_vartime(s: &str) -> Option<Self>
Interpret a string of numbers as a (congruent) prime field element. Does not accept unnecessary leading zeroes or a blank string. Read more
fn from_repr_vartime(repr: Self::Repr) -> Option<Self>
fn from_repr_vartime(repr: Self::Repr) -> Option<Self>
Attempts to convert a byte representation of a field element into an element of this prime field, failing if the input is not canonical (is not smaller than the field’s modulus). Read more
sourceimpl PrimeFieldBits for Scalar
Available on crate feature bits only.
impl PrimeFieldBits for Scalar
bits only.sourcefn to_le_bits(&self) -> ScalarBits
fn to_le_bits(&self) -> ScalarBits
Converts an element of the prime field into a little-endian sequence of bits.
sourcefn char_le_bits() -> ScalarBits
fn char_le_bits() -> ScalarBits
Returns the bits of the field characteristic (the modulus) in little-endian order.
sourceimpl Reduce<UInt<{_: usize}>> for Scalar
impl Reduce<UInt<{_: usize}>> for Scalar
sourcefn from_uint_reduced(w: U256) -> Self
fn from_uint_reduced(w: U256) -> Self
Perform a modular reduction, returning a field element.
sourcefn from_be_bytes_reduced(
bytes: GenericArray<u8, <UInt as ArrayEncoding>::ByteSize>
) -> Self
fn from_be_bytes_reduced(
bytes: GenericArray<u8, <UInt as ArrayEncoding>::ByteSize>
) -> Self
Interpret the given byte array as a big endian integer and perform a modular reduction. Read more
sourcefn from_le_bytes_reduced(
bytes: GenericArray<u8, <UInt as ArrayEncoding>::ByteSize>
) -> Self
fn from_le_bytes_reduced(
bytes: GenericArray<u8, <UInt as ArrayEncoding>::ByteSize>
) -> Self
Interpret the given byte array as a little endian integer and perform a modular reduction. Read more
sourcefn from_be_digest_reduced<D>(digest: D) -> Self where
D: FixedOutput<OutputSize = <UInt as ArrayEncoding>::ByteSize>,
fn from_be_digest_reduced<D>(digest: D) -> Self where
D: FixedOutput<OutputSize = <UInt as ArrayEncoding>::ByteSize>,
Interpret a digest as a big endian integer and perform a modular reduction. Read more
sourcefn from_le_digest_reduced<D>(digest: D) -> Self where
D: FixedOutput<OutputSize = <UInt as ArrayEncoding>::ByteSize>,
fn from_le_digest_reduced<D>(digest: D) -> Self where
D: FixedOutput<OutputSize = <UInt as ArrayEncoding>::ByteSize>,
Interpret a digest as a little endian integer and perform a modular reduction. Read more
sourceimpl ReduceNonZero<UInt<{_: usize}>> for Scalar
impl ReduceNonZero<UInt<{_: usize}>> for Scalar
sourcefn from_uint_reduced_nonzero(w: U256) -> Self
fn from_uint_reduced_nonzero(w: U256) -> Self
Perform a modular reduction, returning a field element.
sourceimpl SignPrimitive<NistP256> for Scalar
Available on crate feature ecdsa-core only.
impl SignPrimitive<NistP256> for Scalar
ecdsa-core only.sourcefn try_sign_prehashed<K>(
&self,
k: K,
z: GenericArray<u8, <<C as Curve>::UInt as ArrayEncoding>::ByteSize>
) -> Result<(Signature<C>, Option<RecoveryId>), Error> where
K: Borrow<Self> + Invert<Output = CtOption<Self>>,
fn try_sign_prehashed<K>(
&self,
k: K,
z: GenericArray<u8, <<C as Curve>::UInt as ArrayEncoding>::ByteSize>
) -> Result<(Signature<C>, Option<RecoveryId>), Error> where
K: Borrow<Self> + Invert<Output = CtOption<Self>>,
Try to sign the prehashed message. Read more
sourcefn try_sign_prehashed_rfc6979<D>(
&self,
z: GenericArray<u8, <<C as Curve>::UInt as ArrayEncoding>::ByteSize>,
ad: &[u8]
) -> Result<(Signature<C>, Option<RecoveryId>), Error> where
Self: From<ScalarCore<C>>,
D: CoreProxy + FixedOutput<OutputSize = <<C as Curve>::UInt as ArrayEncoding>::ByteSize>,
<C as Curve>::UInt: for<'a> From<&'a Self>,
<D as CoreProxy>::Core: BlockSizeUser,
<D as CoreProxy>::Core: BufferKindUser,
<D as CoreProxy>::Core: Clone,
<D as CoreProxy>::Core: Default,
<D as CoreProxy>::Core: FixedOutputCore,
<D as CoreProxy>::Core: HashMarker,
<D as CoreProxy>::Core: OutputSizeUser,
<<D as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>,
<<<D as CoreProxy>::Core as BlockSizeUser>::BlockSize as IsLess<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>>::Output: NonZero,
<<D as CoreProxy>::Core as BufferKindUser>::BufferKind == Eager,
<<D as CoreProxy>::Core as OutputSizeUser>::OutputSize == <D as OutputSizeUser>::OutputSize,
fn try_sign_prehashed_rfc6979<D>(
&self,
z: GenericArray<u8, <<C as Curve>::UInt as ArrayEncoding>::ByteSize>,
ad: &[u8]
) -> Result<(Signature<C>, Option<RecoveryId>), Error> where
Self: From<ScalarCore<C>>,
D: CoreProxy + FixedOutput<OutputSize = <<C as Curve>::UInt as ArrayEncoding>::ByteSize>,
<C as Curve>::UInt: for<'a> From<&'a Self>,
<D as CoreProxy>::Core: BlockSizeUser,
<D as CoreProxy>::Core: BufferKindUser,
<D as CoreProxy>::Core: Clone,
<D as CoreProxy>::Core: Default,
<D as CoreProxy>::Core: FixedOutputCore,
<D as CoreProxy>::Core: HashMarker,
<D as CoreProxy>::Core: OutputSizeUser,
<<D as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>,
<<<D as CoreProxy>::Core as BlockSizeUser>::BlockSize as IsLess<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>>::Output: NonZero,
<<D as CoreProxy>::Core as BufferKindUser>::BufferKind == Eager,
<<D as CoreProxy>::Core as OutputSizeUser>::OutputSize == <D as OutputSizeUser>::OutputSize,
sourcefn try_sign_digest_rfc6979<D>(
&self,
msg_digest: D,
ad: &[u8]
) -> Result<(Signature<C>, Option<RecoveryId>), Error> where
Self: From<ScalarCore<C>>,
D: CoreProxy + FixedOutput<OutputSize = <<C as Curve>::UInt as ArrayEncoding>::ByteSize>,
<C as Curve>::UInt: for<'a> From<&'a Self>,
<D as CoreProxy>::Core: BlockSizeUser,
<D as CoreProxy>::Core: BufferKindUser,
<D as CoreProxy>::Core: Clone,
<D as CoreProxy>::Core: Default,
<D as CoreProxy>::Core: FixedOutputCore,
<D as CoreProxy>::Core: HashMarker,
<D as CoreProxy>::Core: OutputSizeUser,
<<D as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>,
<<<D as CoreProxy>::Core as BlockSizeUser>::BlockSize as IsLess<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>>::Output: NonZero,
<<D as CoreProxy>::Core as BufferKindUser>::BufferKind == Eager,
<<D as CoreProxy>::Core as OutputSizeUser>::OutputSize == <D as OutputSizeUser>::OutputSize,
fn try_sign_digest_rfc6979<D>(
&self,
msg_digest: D,
ad: &[u8]
) -> Result<(Signature<C>, Option<RecoveryId>), Error> where
Self: From<ScalarCore<C>>,
D: CoreProxy + FixedOutput<OutputSize = <<C as Curve>::UInt as ArrayEncoding>::ByteSize>,
<C as Curve>::UInt: for<'a> From<&'a Self>,
<D as CoreProxy>::Core: BlockSizeUser,
<D as CoreProxy>::Core: BufferKindUser,
<D as CoreProxy>::Core: Clone,
<D as CoreProxy>::Core: Default,
<D as CoreProxy>::Core: FixedOutputCore,
<D as CoreProxy>::Core: HashMarker,
<D as CoreProxy>::Core: OutputSizeUser,
<<D as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>,
<<<D as CoreProxy>::Core as BlockSizeUser>::BlockSize as IsLess<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>>::Output: NonZero,
<<D as CoreProxy>::Core as BufferKindUser>::BufferKind == Eager,
<<D as CoreProxy>::Core as OutputSizeUser>::OutputSize == <D as OutputSizeUser>::OutputSize,
sourceimpl SubAssign<&'_ Scalar> for Scalar
impl SubAssign<&'_ Scalar> for Scalar
sourcefn sub_assign(&mut self, rhs: &Scalar)
fn sub_assign(&mut self, rhs: &Scalar)
Performs the -= operation. Read more
sourceimpl SubAssign<Scalar> for Scalar
impl SubAssign<Scalar> for Scalar
sourcefn sub_assign(&mut self, rhs: Scalar)
fn sub_assign(&mut self, rhs: Scalar)
Performs the -= operation. Read more
impl Copy for Scalar
impl DefaultIsZeroes for Scalar
impl Eq for Scalar
Auto Trait Implementations
impl RefUnwindSafe for Scalar
impl Send for Scalar
impl Sync for Scalar
impl Unpin for Scalar
impl UnwindSafe for Scalar
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ConditionallyNegatable for T where
T: ConditionallySelectable,
&'a T: for<'a> Neg,
<&'a T as Neg>::Output == T,
impl<T> ConditionallyNegatable for T where
T: ConditionallySelectable,
&'a T: for<'a> Neg,
<&'a T as Neg>::Output == T,
sourcefn conditional_negate(&mut self, choice: Choice)
fn conditional_negate(&mut self, choice: Choice)
Negate self if choice == Choice(1); otherwise, leave it
unchanged. Read more
impl<T> FmtForward for T
impl<T> FmtForward for T
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. Read more
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
fn fmt_octal(self) -> FmtOctal<Self> where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self> where
Self: Octal,
Causes self to use its Octal implementation when Debug-formatted. Read more
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
fn fmt_list(self) -> FmtList<Self> where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self> where
&'a Self: for<'a> IntoIterator,
Formats each item in a sequence. Read more
impl<T> Pipe for T where
T: ?Sized,
impl<T> Pipe for T where
T: ?Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
Pipes by value. This is generally the method you want to use. Read more
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R where
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R where
R: 'a,
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>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R where
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
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>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R where
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
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.
impl<T> Tap for T
impl<T> Tap for T
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
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self where
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self where
Self: AsRef<R>,
R: ?Sized,
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
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self where
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self where
Self: Deref<Target = T>,
T: ?Sized,
Immutable access to the Deref::Target of a value. Read more
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self where
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self where
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Mutable access to the Deref::Target of a value. Read more
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
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