Struct turbo::b3 []

pub struct b3(_);

A binary number ($fieldwidth digits).

Methods

impl b3

Array-based constructor.

Reports the maximum unsigned integer expressible in this type.

Examples

#![feature(try_from)]
#[macro_use] extern crate finite_fields;

binary_type! { b2, 2 }

fn main() {
  let num: b2 = b2::new([ZERO; 2]);
  assert_eq!(num.max(), (2 as usize).pow(2) - 1);
}

Reports the number of digits in this type.

Copies out the internal data as a fixed-width array.

Shifts the leftmost digit off and pushes a new digit onto the right. Returns a modified copy.

Pops the rightmost digit off and unshifts a new digit onto the left. Returns a modified copy.

Trait Implementations

impl Clone for b3

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Copy for b3

impl PartialEq for b3

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Debug for b3

Formats the value using the given formatter.

impl Display for b3

Formats the value using the given formatter. Read more

impl From<usize> for b3

Fallible conversion by successive division, but pretends like it's not since TryFrom is still unstable.

Examples

#![feature(try_from)]
#[macro_use] extern crate finite_fields;

binary_type! { b2, 2 }

fn main() {
  let zero: b2 = (0 as usize).into();
  assert_eq!(zero, b2::new([ZERO, ZERO]));
   
  let one: b2 = (1 as usize).into();
  assert_eq!(one, b2::new([ZERO, ONE]));
   
  let two: b2 = (2 as usize).into();
  assert_eq!(two, b2::new([ONE, ZERO]));
   
  let three: b2 = (3 as usize).into();
  assert_eq!(three, b2::new([ONE, ONE]));
}

Panics

Panics if the argument is larger than what b2 can hold.

#![feature(try_from)]
#[macro_use] extern crate finite_fields;

binary_type! { b2, 2 }

fn main() {
  let four = b2::from(4 as usize);
}

Performs the conversion.

impl<'a> Index<usize> for b3

The returned type after indexing

The method for the indexing (container[index]) operation

impl IndexMut<usize> for b3

The method for the mutable indexing (container[index]) operation

impl IntoIterator for b3

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

impl<'a> IntoIterator for &'a b3

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

impl FromIterator<b1> for b3

Creates a value from an iterator. Read more

impl Add for b3

Arithmetic addition with overflow error.

The resulting type after applying the + operator

The method for the + operator

impl<'a> Add<b3> for &'a b3

The resulting type after applying the + operator

The method for the + operator

impl<'a> Add<&'a b3> for &'a b3

The resulting type after applying the + operator

The method for the + operator

impl Sub for b3

Arithmetic subtraction with overflow error.

The resulting type after applying the - operator

The method for the - operator

impl<'a> Sub<b3> for &'a b3

The resulting type after applying the - operator

The method for the - operator

impl<'a> Sub<&'a b3> for &'a b3

The resulting type after applying the - operator

The method for the - operator

impl Peano for b3

This implementation is done "in reverse" of the expected logical order; it uses the Add and Sub impls instead of the converse.

Produces the next integer value in the field of self (i.e., increment). Read more

Peano arithmetic function.

Total ordering function.

impl PartialOrd for b3

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl BitAnd for b3

The resulting type after applying the & operator

The method for the & operator

impl<'a> BitAnd<b3> for &'a b3

The resulting type after applying the & operator

The method for the & operator

impl<'a> BitAnd<&'a b3> for &'a b3

The resulting type after applying the & operator

The method for the & operator

impl BitOr for b3

The resulting type after applying the | operator

The method for the | operator

impl<'a> BitOr<b3> for &'a b3

The resulting type after applying the | operator

The method for the | operator

impl<'a> BitOr<&'a b3> for &'a b3

The resulting type after applying the | operator

The method for the | operator

impl BitXor for b3

The resulting type after applying the ^ operator

The method for the ^ operator

impl<'a> BitXor<b3> for &'a b3

The resulting type after applying the ^ operator

The method for the ^ operator

impl<'a> BitXor<&'a b3> for &'a b3

The resulting type after applying the ^ operator

The method for the ^ operator

impl Shr<usize> for b3

The resulting type after applying the >> operator

The method for the >> operator

impl Shl<usize> for b3

The resulting type after applying the << operator

The method for the << operator

impl Mul for b3

Multiplication as repeated addition.

The resulting type after applying the * operator

The method for the * operator

impl<'a> Mul<b3> for &'a b3

The resulting type after applying the * operator

The method for the * operator

impl<'a> Mul<&'a b3> for &'a b3

The resulting type after applying the * operator

The method for the * operator

impl Div for b3

Implementation of division as repeated subtraction.

The resulting type after applying the / operator

The method for the / operator

impl<'a> Div<b3> for &'a b3

The resulting type after applying the / operator

The method for the / operator

impl<'a> Div<&'a b3> for &'a b3

The resulting type after applying the / operator

The method for the / operator