Check whether two strings are anagrams Inspired by Monday's Reddit daily programmer challenge, I wrote a function to check whether two strings are anagrams. It doesn't take the same input as the challenge, though, since I don't want to handle user input (yet). 

For the lazy ones, the task is to write a function that checks whether the letters in the first word can be shuffled (and upcased/downcased) to create the second word. Punctuation and whitespace isn't important.

This is more or less the first code I've written in Rust, so any kind of feedback is welcome:

/// Returns the sorted alphabetic symbols of a string in lowercase.
fn normalize(s : &amp;str) -&gt; Vec&lt;char&gt; {
    let mut characters : Vec&lt;char&gt; = s.to_lowercase()
        .chars()
        .filter(|x| x.is_alphabetic())
        .collect();
    characters.sort();
    characters
}

/// Returns true if the sets of alphabetic symbols coincide.
pub fn is_anagram(a : &amp;str, b : &amp;str) -&gt; bool{
    normalize(a) == normalize(b)
}

#[test]
fn is_anagram_test() {
    assert!( is_anagram("Clint Eastwood","Old West Action"));
    assert!( is_anagram("wisdom","mid sow"));
    assert!(!is_anagram("Reddit","Eat Dirt"));
    assert!( is_anagram("Schoolmaster","The classroom"));
    assert!( is_anagram("Vacation Times", "I'm Not as Active"));
    assert!( is_anagram("12431b53c11a5324", "abc"));
}


I'm not particularly fond of using a mut Vec&lt;char&gt; just to use sort, but I guess it's the same situation as in C++, where std::sort will also modify a container in-place. The code was written with previous experience in C++, but with the following Haskell code in mind:

isAnagramOf :: String -&gt; String -&gt; Bool
isAnagramOf = (==) `on` (sort . map toLower . filter isLetter)
There is no space before : in types.
There is a space after the return type
There is a space between function arguments, after the comma.
str::to_lowercase allocates a new string. It's a potential optimization to iterate through each character and convert to lowercase. Profiling should be done if performance matters.
Could use itertools sorted to reduce some boilerplate. Does the same thing under the hood.




extern crate itertools;
use itertools::Itertools;

/// Returns the sorted alphabetic symbols of a string in lowercase.
fn normalize(s: &amp;str) -&gt; Vec&lt;char&gt; {
    s.chars()
        .flat_map(char::to_lowercase)
        .filter(|c| c.is_alphabetic())
        .sorted()
}

/// Returns true if the sets of alphabetic symbols coincide.
pub fn is_anagram(a: &amp;str, b: &amp;str) -&gt; bool {
    normalize(a) == normalize(b)
}

#[test]
fn is_anagram_test() {
    assert!( is_anagram("Clint Eastwood", "Old West Action"));
    assert!( is_anagram("wisdom", "mid sow"));
    assert!(!is_anagram("Reddit", "Eat Dirt"));
    assert!( is_anagram("Schoolmaster", "The classroom"));
    assert!( is_anagram("Vacation Times", "I'm Not as Active"));
    assert!( is_anagram("12431b53c11a5324", "abc"));
}


Ultimately, you won't be able to achieve the same particular kind of elegance as the Haskell solution, but I'd hope that the performance would be better.