Struct finite_fields::binary_static::b2
[−]
[src]
pub struct b2(_);
A two-digit binary number.
Methods
impl b2[src]
fn new(vals: [b1; 2]) -> b2
Array-based constructor.
fn max(&self) -> usize
Reports the maximum unsigned integer expressible in this type.
fn len(&self) -> usize
Reports the number of digits in this type.
fn iter(self) -> Iter
fn bits(&self) -> [b1; 2]
Copies out the internal data as a fixed-width array.
fn shift_concat(&self, val: b1) -> b2
Shifts the leftmost digit off and pushes a new digit onto the right.
fn unshift_concat(&self, val: b1) -> b2
Pops the rightmost digit off and unshifts a new digit onto the left.
Trait Implementations
impl Clone for b2[src]
fn clone(&self) -> b2
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0
Performs copy-assignment from source. Read more
impl Copy for b2[src]
impl PartialEq for b2[src]
fn eq(&self, __arg_0: &b2) -> bool
This method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, __arg_0: &b2) -> bool
This method tests for !=.
impl Debug for b2[src]
impl Display for b2[src]
impl TryFrom<usize> for b2[src]
Fallible conversion by successive division.
Examples
#![feature(try_from)] extern crate finite_fields; use std::convert::{TryFrom, TryInto}; use finite_fields::binary_static::{b2, ZERO, ONE}; let zero: b2 = (0 as usize).try_into().unwrap(); assert_eq!(zero, b2::new([ZERO, ZERO])); let one: b2 = (1 as usize).try_into().unwrap(); assert_eq!(one, b2::new([ZERO, ONE])); let two: b2 = (2 as usize).try_into().unwrap(); assert_eq!(two, b2::new([ONE, ZERO])); let three: b2 = (3 as usize).try_into().unwrap(); assert_eq!(three, b2::new([ONE, ONE])); let four = b2::try_from(4 as usize); assert!(four.is_err());
type Err = ConversionError
try_from)The type returned in the event of a conversion error.
fn try_from(val: usize) -> Result<Self, Self::Err>
try_from)Performs the conversion.
impl<'a> Index<usize> for b2[src]
type Output = b1
The returned type after indexing
fn index<'b>(&'b self, index: usize) -> &'b b1
The method for the indexing (container[index]) operation
impl IndexMut<usize> for b2[src]
fn index_mut<'a>(&'a mut self, index: usize) -> &'a mut b1
The method for the mutable indexing (container[index]) operation
impl IntoIterator for b2[src]
type Item = b1
The type of the elements being iterated over.
type IntoIter = IntoIter<b1>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more
impl<'a> IntoIterator for &'a b2[src]
type Item = &'a b1
The type of the elements being iterated over.
type IntoIter = Iter<'a, b1>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more
impl FromIterator<b1> for b2[src]
fn from_iter<I: IntoIterator<Item=b1>>(iter: I) -> Self
Creates a value from an iterator. Read more
impl Add for b2[src]
Arithmetic addition with overflow error.
type Output = Result<Self, OverflowError>
The resulting type after applying the + operator
fn add(self, other: b2) -> Result<b2, OverflowError>
The method for the + operator
impl<'a> Add<b2> for &'a b2[src]
type Output = Result<b2, OverflowError>
The resulting type after applying the + operator
fn add(self, other: b2) -> Result<b2, OverflowError>
The method for the + operator
impl<'a> Add<&'a b2> for &'a b2[src]
type Output = Result<b2, OverflowError>
The resulting type after applying the + operator
fn add(self, other: &b2) -> Result<b2, OverflowError>
The method for the + operator
impl Sub for b2[src]
Wrapping arithmetic subtraction with overflow error.
type Output = Result<b2, OverflowError>
The resulting type after applying the - operator
fn sub(self, other: b2) -> Result<b2, OverflowError>
The method for the - operator
impl<'a> Sub<b2> for &'a b2[src]
type Output = Result<b2, OverflowError>
The resulting type after applying the - operator
fn sub(self, other: b2) -> Result<b2, OverflowError>
The method for the - operator
impl<'a> Sub<&'a b2> for &'a b2[src]
type Output = Result<b2, OverflowError>
The resulting type after applying the - operator
fn sub(self, other: &b2) -> Result<b2, OverflowError>
The method for the - operator
impl Peano for b2[src]
This implementation is done "in reverse" of the expected logical order; it
uses the Add and Sub impls instead of the converse.
fn successor(&self) -> Result<b2, OverflowError>
Produces the next integer value in the field of self (i.e., increment).
fn predecessor(&self) -> Result<b2, OverflowError>
Peano arithmetic function.
fn cmp(&self, other: &Self) -> Ordering
Total ordering function.
impl PartialOrd for b2[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self and other values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool1.0.0
This method tests less than (for self and other) and is used by the < operator. Read more
fn le(&self, other: &Rhs) -> bool1.0.0
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
fn gt(&self, other: &Rhs) -> bool1.0.0
This method tests greater than (for self and other) and is used by the > operator. Read more
fn ge(&self, other: &Rhs) -> bool1.0.0
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
impl BitAnd for b2[src]
type Output = Self
The resulting type after applying the & operator
fn bitand(self, other: b2) -> Self
The method for the & operator
impl<'a> BitAnd<b2> for &'a b2[src]
type Output = b2
The resulting type after applying the & operator
fn bitand(self, other: b2) -> b2
The method for the & operator
impl<'a> BitAnd<&'a b2> for &'a b2[src]
type Output = b2
The resulting type after applying the & operator
fn bitand(self, other: &b2) -> b2
The method for the & operator
impl BitOr for b2[src]
type Output = Self
The resulting type after applying the | operator
fn bitor(self, other: b2) -> Self
The method for the | operator
impl<'a> BitOr<b2> for &'a b2[src]
type Output = b2
The resulting type after applying the | operator
fn bitor(self, other: b2) -> b2
The method for the | operator
impl<'a> BitOr<&'a b2> for &'a b2[src]
type Output = b2
The resulting type after applying the | operator
fn bitor(self, other: &b2) -> b2
The method for the | operator
impl BitXor for b2[src]
type Output = Self
The resulting type after applying the ^ operator
fn bitxor(self, other: b2) -> Self
The method for the ^ operator
impl<'a> BitXor<b2> for &'a b2[src]
type Output = b2
The resulting type after applying the ^ operator
fn bitxor(self, other: b2) -> b2
The method for the ^ operator
impl<'a> BitXor<&'a b2> for &'a b2[src]
type Output = b2
The resulting type after applying the ^ operator
fn bitxor(self, other: &b2) -> b2
The method for the ^ operator
impl Shr<usize> for b2[src]
type Output = Self
The resulting type after applying the >> operator
fn shr(self, rhs: usize) -> Self
The method for the >> operator
impl Shl<usize> for b2[src]
type Output = Self
The resulting type after applying the << operator
fn shl(self, rhs: usize) -> Self
The method for the << operator
impl Mul for b2[src]
type Output = Result<b2, OverflowError>
The resulting type after applying the * operator
fn mul(self, other: b2) -> Result<b2, OverflowError>
The method for the * operator
impl<'a> Mul<b2> for &'a b2[src]
type Output = Result<b2, OverflowError>
The resulting type after applying the * operator
fn mul(self, other: b2) -> Result<b2, OverflowError>
The method for the * operator
impl<'a> Mul<&'a b2> for &'a b2[src]
type Output = Result<b2, OverflowError>
The resulting type after applying the * operator
fn mul(self, other: &'a b2) -> Result<b2, OverflowError>
The method for the * operator
impl Div<b2> for b2[src]
Implementation of division as repeated subtraction.
type Output = Result<b2, DivisionError>
The resulting type after applying the / operator
fn div(self, other: b2) -> Result<b2, DivisionError>
The method for the / operator
impl<'a> Div<b2> for &'a b2[src]
type Output = Result<b2, DivisionError>
The resulting type after applying the / operator
fn div(self, other: b2) -> Result<b2, DivisionError>
The method for the / operator
impl<'a> Div<&'a b2> for &'a b2[src]
type Output = Result<b2, DivisionError>
The resulting type after applying the / operator
fn div(self, other: &b2) -> Result<b2, DivisionError>
The method for the / operator