pub fn hamming_distance(a: &str, b: &str) -> Result<usize, &'static str> {
    if a.len() != b.len() {
        return Result::Err("Length is not same");
    }

    let count = a.chars()
        .zip(b.chars())
        .filter(|&(an, bn)| an != bn)
        .count();

    Result::Ok(count)
}

pub fn hamming_distance<'a, 'b>(a: &'a str, b: &'a str) -> Result<usize, &'b str> {
    if a.len() != b.len() {
        return Err("Length is not same");
    }

    let max = a.len();

    let mut ai = a.chars();
    let mut bi = b.chars();

    let mut count = 0;

    for _ in 0..max {
        if ai.next() != bi.next() {
            count += 1;
        }
    }

    Ok(count)
}

--- 
+++ 
@@ -1,12 +1,20 @@
-pub fn hamming_distance(a: &str, b: &str) -> Result<usize, &'static str> {
+pub fn hamming_distance<'a, 'b>(a: &'a str, b: &'a str) -> Result<usize, &'b str> {
     if a.len() != b.len() {
-        return Result::Err("Length is not same");
+        return Err("Length is not same");
     }
 
-    let count = a.chars()
-        .zip(b.chars())
-        .filter(|&(an, bn)| an != bn)
-        .count();
+    let max = a.len();
 
-    Result::Ok(count)
+    let mut ai = a.chars();
+    let mut bi = b.chars();
+
+    let mut count = 0;
+
+    for _ in 0..max {
+        if ai.next() != bi.next() {
+            count += 1;
+        }
+    }
+
+    Ok(count)
 }
Use a smart way stolen from others

I like functional programming style now
