pub trait CheckedHammingDistance<RHS = Self> {
    // Required method
    fn checked_hamming_distance(self, other: RHS) -> Option<u64>;
}
Expand description

Returns the Hamming distance between two numbers, or the number of bit flips needed to turn one into the other.

This trait allows for the possibility of the distance being undefined for some pairs of numbers, in which case checked_hamming_distance should return None.

Required Methods§

source

fn checked_hamming_distance(self, other: RHS) -> Option<u64>

Implementations on Foreign Types§

source§

impl CheckedHammingDistance for i8

source§

fn checked_hamming_distance(self, other: i8) -> Option<u64>

Returns the Hamming distance between two numbers, or the number of bit flips needed to turn one into the other.

If the two numbers have opposite signs, then the number of flips would be infinite, so the result is None.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl CheckedHammingDistance for i16

source§

fn checked_hamming_distance(self, other: i16) -> Option<u64>

Returns the Hamming distance between two numbers, or the number of bit flips needed to turn one into the other.

If the two numbers have opposite signs, then the number of flips would be infinite, so the result is None.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl CheckedHammingDistance for i32

source§

fn checked_hamming_distance(self, other: i32) -> Option<u64>

Returns the Hamming distance between two numbers, or the number of bit flips needed to turn one into the other.

If the two numbers have opposite signs, then the number of flips would be infinite, so the result is None.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl CheckedHammingDistance for i64

source§

fn checked_hamming_distance(self, other: i64) -> Option<u64>

Returns the Hamming distance between two numbers, or the number of bit flips needed to turn one into the other.

If the two numbers have opposite signs, then the number of flips would be infinite, so the result is None.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl CheckedHammingDistance for i128

source§

fn checked_hamming_distance(self, other: i128) -> Option<u64>

Returns the Hamming distance between two numbers, or the number of bit flips needed to turn one into the other.

If the two numbers have opposite signs, then the number of flips would be infinite, so the result is None.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl CheckedHammingDistance for isize

source§

fn checked_hamming_distance(self, other: isize) -> Option<u64>

Returns the Hamming distance between two numbers, or the number of bit flips needed to turn one into the other.

If the two numbers have opposite signs, then the number of flips would be infinite, so the result is None.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Implementors§