Function stringmetrics::hamming_iter
source · pub fn hamming_iter<I: IntoIterator<Item = T>, T: PartialEq>(
a: I,
b: I
) -> Result<u32, LengthMismatchError>
Expand description
Apply the hamming function to iterators
This is useful for avoiding the need to collect data before performing the
calculation. a
and b
are mutable iterators; mutability is required as
the iterator will be consumed.
Returns a Result
with Ok(v)
if the function completed successfully, or
Err(s)
if there was an iterator length mismatch.
Example
use stringmetrics::hamming_iter;
let a = "abcdefg";
let b = "aaadefa";
assert_eq!(hamming_iter(a.chars(), b.chars()), Ok(3));
assert_eq!(hamming_iter(1..3, 2..4), Ok(2));
Errors
Returns a LengthMismatchError
if the two iterators are not of the same
length