Function triple_accel::hamming::hamming_naive[][src]

pub fn hamming_naive(a: &[u8], b: &[u8]) -> u32
Expand description

Returns the hamming distance between two strings by naively counting mismatches.

The length of a and b must be the same.

Arguments

  • a - first string (slice)
  • b - second string (slice)

Panics

  • If the length of a does not equal the length of b.

Example

let dist = hamming_naive(b"abc", b"abd");

assert!(dist == 1);