Skip to main content

GF2

Struct GF2 

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

Element of the Galois field GF(2) = {0, 1}.

The smallest finite field. Addition is XOR, multiplication is AND. Every nonzero element is its own inverse (both additive and multiplicative).

Implementations§

Source§

impl GF2

Source

pub const ZERO: Self

Source

pub const ONE: Self

Source

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

Create from a u8 value (reduces mod 2).

Source

pub const fn from_bool(value: bool) -> Self

Create from a bool.

Source

pub const fn value(self) -> u8

The underlying value (0 or 1).

Source

pub const fn is_zero_element(self) -> bool

Whether this is the zero element.

Source

pub const fn is_one(self) -> bool

Whether this is the one (unity) element.

Source

pub const fn inverse(self) -> Option<Self>

Multiplicative inverse. Returns None for zero.

Trait Implementations§

Source§

impl Add for GF2

Source§

type Output = GF2

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl AddAssign for GF2

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl Clone for GF2

Source§

fn clone(&self) -> GF2

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GF2

Source§

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

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

impl Default for GF2

Source§

fn default() -> GF2

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

impl Display for GF2

Source§

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

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

impl From<GF2> for bool

Source§

fn from(value: GF2) -> Self

Converts to this type from the input type.
Source§

impl From<GF2> for u8

Source§

fn from(value: GF2) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for GF2

Source§

fn from(value: bool) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for GF2

Source§

fn from(value: u8) -> Self

Converts to this type from the input type.
Source§

impl Hash for GF2

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Mul for GF2

Source§

type Output = GF2

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl MulAssign for GF2

Source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
Source§

impl Neg for GF2

Source§

type Output = GF2

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl One for GF2

Source§

fn one() -> Self

Returns the multiplicative identity element of Self, 1. Read more
Source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
Source§

fn is_one(&self) -> bool
where Self: PartialEq,

Returns true if self is equal to the multiplicative identity. Read more
Source§

impl PartialEq for GF2

Source§

fn eq(&self, other: &GF2) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 Sub for GF2

Source§

type Output = GF2

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl SubAssign for GF2

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl Zero for GF2

Source§

fn zero() -> Self

Returns the additive identity element of Self, 0. Read more
Source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
Source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
Source§

impl Copy for GF2

Source§

impl Eq for GF2

Source§

impl StructuralPartialEq for GF2

Auto Trait Implementations§

§

impl Freeze for GF2

§

impl RefUnwindSafe for GF2

§

impl Send for GF2

§

impl Sync for GF2

§

impl Unpin for GF2

§

impl UnsafeUnpin for GF2

§

impl UnwindSafe for GF2

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<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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> 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§

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.