#[repr(u8)]
pub enum Parity {
Even,
Odd,
}Expand description
Data type representing the parity of a Row. To generate these, you probably want to use
Row::parity. Note that Row::parity always performs a heap allocation and is
linear-time in the Stage of the Row. If you are using Paritys as optimisations
within hot code I would recommend computing them upfront on your input Rows and then
tracking them by hand, probably using the * operator.
Note that it would be quite cheap for Rows to track their Parity all the time, but that
would result in less-than ideal data layouts and doesn’t fit with the ‘only pay for what you
use’ design goal of this library.
Variants
Even
A given Row requires an even number of swaps to return to
rounds. This is also often called in course or positive. The
parity of rounds on every Stage.
Odd
A given Row requires an odd number of swaps to return to
rounds. This is also often called out of course or negative.
Implementations
sourceimpl Parity
impl Parity
sourcepub fn from_is_odd(v: bool) -> Self
pub fn from_is_odd(v: bool) -> Self
Maps true to Parity::Even and false to Parity::Odd. On most machines, this
will not actually do anything and be removed by the compiler.
sourcepub fn from_number(v: usize) -> Parity
pub fn from_number(v: usize) -> Parity
Returns the Parity of a given number.
sourcepub fn zero_or_one(self) -> u8
pub fn zero_or_one(self) -> u8
Returns the Parity of a given number.
sourcepub fn plus_or_minus(self) -> char
pub fn plus_or_minus(self) -> char
Returns the Parity of a given number.
Trait Implementations
sourceimpl Mul<Parity> for Parity
impl Mul<Parity> for Parity
sourcefn mul(self, rhs: Self) -> Self::Output
fn mul(self, rhs: Self) -> Self::Output
‘Multiply’ two Paritys together (this corresponds to xor/uncarried addition where
Even is 0 and Odd is 1). Also, if you have a Row r1 with Parity p1 and
another Row r2 with Parity p2 then (r1 * r2).parity() will always equal p1 * p2. Thus, this can be used to convert calls to Row::parity into an extremely
cheap (likely single-cycle) update function.
impl Copy for Parity
impl Eq for Parity
impl StructuralEq for Parity
impl StructuralPartialEq for Parity
Auto Trait Implementations
impl RefUnwindSafe for Parity
impl Send for Parity
impl Sync for Parity
impl Unpin for Parity
impl UnwindSafe for Parity
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key and return true if they are equal.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more