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

I like functional programming style now
