pub trait IsField: Debug + Clone {
type BaseType: Clone + Debug + Unpin + ByteConversion + Default;
Show 14 methods
// Required methods
fn add(a: &Self::BaseType, b: &Self::BaseType) -> Self::BaseType;
fn mul(a: &Self::BaseType, b: &Self::BaseType) -> Self::BaseType;
fn sub(a: &Self::BaseType, b: &Self::BaseType) -> Self::BaseType;
fn neg(a: &Self::BaseType) -> Self::BaseType;
fn inv(a: &Self::BaseType) -> Result<Self::BaseType, FieldError>;
fn div(
a: &Self::BaseType,
b: &Self::BaseType,
) -> Result<Self::BaseType, FieldError>;
fn eq(a: &Self::BaseType, b: &Self::BaseType) -> bool;
fn one() -> Self::BaseType;
fn from_u64(x: u64) -> Self::BaseType;
fn from_base_type(x: Self::BaseType) -> Self::BaseType;
// Provided methods
fn double(a: &Self::BaseType) -> Self::BaseType { ... }
fn square(a: &Self::BaseType) -> Self::BaseType { ... }
fn pow<T>(a: &Self::BaseType, exponent: T) -> Self::BaseType
where T: IsUnsignedInteger { ... }
fn zero() -> Self::BaseType { ... }
}
Expand description
Trait to add field behaviour to a struct.
Required Associated Types§
Required Methods§
Sourcefn mul(a: &Self::BaseType, b: &Self::BaseType) -> Self::BaseType
fn mul(a: &Self::BaseType, b: &Self::BaseType) -> Self::BaseType
Returns the multiplication of a
and b
.
Sourcefn sub(a: &Self::BaseType, b: &Self::BaseType) -> Self::BaseType
fn sub(a: &Self::BaseType, b: &Self::BaseType) -> Self::BaseType
Returns the subtraction of a
and b
.
Sourcefn inv(a: &Self::BaseType) -> Result<Self::BaseType, FieldError>
fn inv(a: &Self::BaseType) -> Result<Self::BaseType, FieldError>
Returns the multiplicative inverse of a
.
Sourcefn div(
a: &Self::BaseType,
b: &Self::BaseType,
) -> Result<Self::BaseType, FieldError>
fn div( a: &Self::BaseType, b: &Self::BaseType, ) -> Result<Self::BaseType, FieldError>
Returns the division of a
and b
.
Sourcefn eq(a: &Self::BaseType, b: &Self::BaseType) -> bool
fn eq(a: &Self::BaseType, b: &Self::BaseType) -> bool
Returns a boolean indicating whether a
and b
are equal or not.
Sourcefn from_u64(x: u64) -> Self::BaseType
fn from_u64(x: u64) -> Self::BaseType
Returns the element x * 1
where 1 is the multiplicative neutral element.
Sourcefn from_base_type(x: Self::BaseType) -> Self::BaseType
fn from_base_type(x: Self::BaseType) -> Self::BaseType
Takes as input an element of BaseType and returns the internal representation of that element in the field.
Provided Methods§
fn pow<T>(a: &Self::BaseType, exponent: T) -> Self::BaseTypewhere
T: IsUnsignedInteger,
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.