// Returns true if the strings underlying two tokens are of the same length
// but with one character different.
Returns true if the strings underlying two tokens are of the same length
but with one character different.
Returns true if the strings underlying two tokens are of the same length but with one character different .
fn one_character_different<'b>(str1: &'b [u8], str2: &'b [u8]) -> bool {
        if str1.len() != str2.len() {
            false
        } else {
            // both strings have same length
            let str_len = str1.len();
            for i in 0..str_len {
                if str1[i] != str2[i] {
                    // Allow only one mistake
                    return str1[i + 1..] == str2[i + 1..];
                }
            }
            true
        }
    }
fn one_character_different < ' b > ( str1 : & ' b [ u8 ] , str2 : & ' b [ u8 ] ) -> bool { if str1 . len ( ) != str2 . len ( ) { false } else { // both strings have same length let str_len = str1 . len ( ) ; for i in 0 .. str_len { if str1 [ i ] != str2 [ i ] { // Allow only one mistake return str1 [ i + 1 .. ] == str2 [ i + 1 .. ] ; } } true } }
Returns true if the strings underlying two tokens are of the same length
but with one character different.
Returns true if the strings underlying two tokens are of the same length but with one character different .
str1
&'b [u8]
str2
&'b [u8]