Trait Parity

Source
pub trait Parity {
    // Required methods
    fn even(self) -> bool;
    fn odd(self) -> bool;
}
Expand description

Determines whether a number is even or odd.

Required Methods§

Source

fn even(self) -> bool

Determines whether a number is even.

Source

fn odd(self) -> bool

Determines whether a number is odd.

Implementations on Foreign Types§

Source§

impl Parity for i8

Source§

fn even(self) -> bool

Tests whether a number is even.

$f(x) = (2|x)$.

$f(x) = (\exists k \in \N \ x = 2k)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

fn odd(self) -> bool

Tests whether a number is odd.

$f(x) = (2\nmid x)$.

$f(x) = (\exists k \in \N \ x = 2k+1)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl Parity for i16

Source§

fn even(self) -> bool

Tests whether a number is even.

$f(x) = (2|x)$.

$f(x) = (\exists k \in \N \ x = 2k)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

fn odd(self) -> bool

Tests whether a number is odd.

$f(x) = (2\nmid x)$.

$f(x) = (\exists k \in \N \ x = 2k+1)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl Parity for i32

Source§

fn even(self) -> bool

Tests whether a number is even.

$f(x) = (2|x)$.

$f(x) = (\exists k \in \N \ x = 2k)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

fn odd(self) -> bool

Tests whether a number is odd.

$f(x) = (2\nmid x)$.

$f(x) = (\exists k \in \N \ x = 2k+1)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl Parity for i64

Source§

fn even(self) -> bool

Tests whether a number is even.

$f(x) = (2|x)$.

$f(x) = (\exists k \in \N \ x = 2k)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

fn odd(self) -> bool

Tests whether a number is odd.

$f(x) = (2\nmid x)$.

$f(x) = (\exists k \in \N \ x = 2k+1)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl Parity for i128

Source§

fn even(self) -> bool

Tests whether a number is even.

$f(x) = (2|x)$.

$f(x) = (\exists k \in \N \ x = 2k)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

fn odd(self) -> bool

Tests whether a number is odd.

$f(x) = (2\nmid x)$.

$f(x) = (\exists k \in \N \ x = 2k+1)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl Parity for isize

Source§

fn even(self) -> bool

Tests whether a number is even.

$f(x) = (2|x)$.

$f(x) = (\exists k \in \N \ x = 2k)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

fn odd(self) -> bool

Tests whether a number is odd.

$f(x) = (2\nmid x)$.

$f(x) = (\exists k \in \N \ x = 2k+1)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl Parity for u8

Source§

fn even(self) -> bool

Tests whether a number is even.

$f(x) = (2|x)$.

$f(x) = (\exists k \in \N \ x = 2k)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

fn odd(self) -> bool

Tests whether a number is odd.

$f(x) = (2\nmid x)$.

$f(x) = (\exists k \in \N \ x = 2k+1)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl Parity for u16

Source§

fn even(self) -> bool

Tests whether a number is even.

$f(x) = (2|x)$.

$f(x) = (\exists k \in \N \ x = 2k)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

fn odd(self) -> bool

Tests whether a number is odd.

$f(x) = (2\nmid x)$.

$f(x) = (\exists k \in \N \ x = 2k+1)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl Parity for u32

Source§

fn even(self) -> bool

Tests whether a number is even.

$f(x) = (2|x)$.

$f(x) = (\exists k \in \N \ x = 2k)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

fn odd(self) -> bool

Tests whether a number is odd.

$f(x) = (2\nmid x)$.

$f(x) = (\exists k \in \N \ x = 2k+1)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl Parity for u64

Source§

fn even(self) -> bool

Tests whether a number is even.

$f(x) = (2|x)$.

$f(x) = (\exists k \in \N \ x = 2k)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

fn odd(self) -> bool

Tests whether a number is odd.

$f(x) = (2\nmid x)$.

$f(x) = (\exists k \in \N \ x = 2k+1)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl Parity for u128

Source§

fn even(self) -> bool

Tests whether a number is even.

$f(x) = (2|x)$.

$f(x) = (\exists k \in \N \ x = 2k)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

fn odd(self) -> bool

Tests whether a number is odd.

$f(x) = (2\nmid x)$.

$f(x) = (\exists k \in \N \ x = 2k+1)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl Parity for usize

Source§

fn even(self) -> bool

Tests whether a number is even.

$f(x) = (2|x)$.

$f(x) = (\exists k \in \N \ x = 2k)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

fn odd(self) -> bool

Tests whether a number is odd.

$f(x) = (2\nmid x)$.

$f(x) = (\exists k \in \N \ x = 2k+1)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Implementors§