Skip to main content

Ring

Trait Ring 

Source
pub trait Ring: Unit + PartialEq {
    const ONE: Self;

    // Required methods
    fn add(self, other: Self) -> Self;
    fn mul(self, other: Self) -> Self;
}
Expand description

The arithmetic a value type needs to appear in a linear equation.

Unit supplies zero and cloning; this adds one, addition, and multiplication, which is what evaluating Σ weight_i · value_i and giving a bare wire the weight one require.

The integer units form the Boolean ring: addition is XOR, multiplication is AND, and one is all ones. A weight is then a bit mask and an equation is an XOR relation between masked wires, which is what a statement about a byte-oriented permutation needs. A field unit uses its field arithmetic.

Required Associated Constants§

Source

const ONE: Self

The multiplicative identity.

Required Methods§

Source

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

Source

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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Ring for u8

Source§

const ONE: Self

Source§

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

Source§

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

Source§

impl Ring for u32

Source§

const ONE: Self

Source§

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

Source§

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

Source§

impl Ring for u64

Source§

const ONE: Self

Source§

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

Source§

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

Source§

impl Ring for u128

Source§

const ONE: Self

Source§

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

Source§

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

Implementors§