Jaccard distance between strings in Rust
Let's start by removing unused code, the whole normalize function and the line s1_shingles.len() as f64.

Then, in order to actually be able to call your functions easily, we change all String arguments into &amp;str. You usually want to accept &amp;str as more types can provide it. In this case, string literals are the big example.

Let's do shingles in a big bang!

fn shingles(s: &amp;str) -&gt; HashSet&lt;String&gt; {
    let chars: Vec&lt;_&gt; = s.chars().collect();
    chars.windows(2).map(|w| w.iter().cloned().collect()).collect()
}


We start by getting all the characters once into a vector. Now that we have a slice (through the Vec), we can use windows, which gives overlapping views into the slice. We then convert each window into an iterator of char using cloned and then into a string using collect. We convert  the overall iterator into a HashSet, also using collect. Look at that type inference go!

Note that now we have a parameter to windows that allows you to extend to arbitrary-sized n-grams!

The other optimization is to avoid collecting into a collection if we just want the count of elements:

let inter = s1_shingles.intersection(&amp;s2_shingles).count();
let union = s1_shingles.union(&amp;s2_shingles).count();


All together, it now looks like:

use std::collections::HashSet;

fn shingles(s: &amp;str) -&gt; HashSet&lt;String&gt; {
    let chars: Vec&lt;_&gt; = s.chars().collect();
    chars.windows(2).map(|w| w.iter().cloned().collect()).collect()
}

fn jaccard_distance(s1: &amp;str, s2: &amp;str) -&gt; f64 {
    let s1_shingles = shingles(s1);
    let s2_shingles = shingles(s2);
    let inter = s1_shingles.intersection(&amp;s2_shingles).count();
    let union = s1_shingles.union(&amp;s2_shingles).count();
    (inter as f64) / (union as f64)
}

fn main() {
    println!("{}", jaccard_distance("Pear", "Peach"));
}


Edit

And of course now I see that if I were to scroll down a bit, I'd see that you do use normalize. Oops! You should still accept a &amp;str, the only change you need to make is to take a reference to the Strings:

println!("'{}' vs '{}' ... \t {}", s1, s2,
         jaccard_distance(&amp;normal_s1, &amp;normal_s2));