pub trait Elem:
'static
+ Clone
+ Copy
+ Send
+ Sync
+ Debug
+ Sized
+ Neg<Output = Self>
+ SubAssign
+ PartialEq
+ Eq
+ Clone
+ Copy
+ NoUninit
+ CheckedBitPattern
+ Default
+ Add<Self, Output = Self>
+ Sub<Self, Output = Self>
+ Mul<Self, Output = Self>
+ AddAssign<Self>
+ SubAssign<Self>
+ MulAssign<Self> {
const INVALID: Self;
const ZERO: Self;
const ONE: Self;
const WORDS: usize;
Show 15 methods
// Required methods
fn inv(self) -> Self;
fn random(rng: &mut impl RngCore) -> Self;
fn from_u64(val: u64) -> Self;
fn to_u32_words(&self) -> Vec<u32>;
fn from_u32_words(val: &[u32]) -> Self;
fn is_valid(&self) -> bool;
fn is_reduced(&self) -> bool;
// Provided methods
fn pow(self, exp: usize) -> Self { ... }
fn valid_or_zero(&self) -> Self { ... }
fn ensure_valid(&self) -> &Self { ... }
fn ensure_reduced(&self) -> &Self { ... }
fn as_u32_slice(elems: &[Self]) -> &[u32] { ... }
fn as_u32_slice_unchecked(elems: &[Self]) -> &[u32] { ... }
fn from_u32_slice(u32s: &[u32]) -> &[Self] { ... }
fn try_from_u32_slice(u32s: &[u32]) -> Result<&[Self], CheckedCastError> { ... }
}Expand description
Subfield elements that can be compared, copied, and operated on via multiplication, addition, and subtraction
Required Associated Constants§
Required Methods§
Sourcefn to_u32_words(&self) -> Vec<u32>
fn to_u32_words(&self) -> Vec<u32>
Represent a field element as a sequence of u32s
Sourcefn from_u32_words(val: &[u32]) -> Self
fn from_u32_words(val: &[u32]) -> Self
Interpret a sequence of u32s as a field element
Sourcefn is_valid(&self) -> bool
fn is_valid(&self) -> bool
Returns true if this element is not INVALID. Unlike most methods, this may be called on an INVALID element.
Sourcefn is_reduced(&self) -> bool
fn is_reduced(&self) -> bool
Returns true if this element is represented in reduced/normalized form. Every element has exactly one reduced form. For a field of prime order P, this typically means the underlying data is < P, and for an extension field, this typically means every component is in reduced form.
Provided Methods§
Sourcefn valid_or_zero(&self) -> Self
fn valid_or_zero(&self) -> Self
Returns 0 if this element is INVALID, else the value of this element. Unlike most methods, this may be called on an INVALID element.
Sourcefn ensure_valid(&self) -> &Self
fn ensure_valid(&self) -> &Self
Returns this element, but checks to make sure it’s valid.
Sourcefn ensure_reduced(&self) -> &Self
fn ensure_reduced(&self) -> &Self
Returns this element, but checks to make sure it’s in reduced form.
Sourcefn as_u32_slice(elems: &[Self]) -> &[u32]
fn as_u32_slice(elems: &[Self]) -> &[u32]
Interprets a slice of these elements as u32s. These elements may not be INVALID.
Sourcefn as_u32_slice_unchecked(elems: &[Self]) -> &[u32]
fn as_u32_slice_unchecked(elems: &[Self]) -> &[u32]
Interprets a slice of these elements as u32s. These elements may potentially be INVALID.
Sourcefn from_u32_slice(u32s: &[u32]) -> &[Self]
fn from_u32_slice(u32s: &[u32]) -> &[Self]
Interprets a slice of u32s as a slice of these elements. These elements may not be INVALID.
Sourcefn try_from_u32_slice(u32s: &[u32]) -> Result<&[Self], CheckedCastError>
fn try_from_u32_slice(u32s: &[u32]) -> Result<&[Self], CheckedCastError>
Interprets a slice of u32s as a slice of these elements. These elements may not be INVALID.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".