Crate is_anagram [−] [src]
A clever way to find anagrams
Map each of the 26 English charaters A, B, C, D, ... [for simplicity] to a prime number. Then multiply the characters of each word. Since every integer is a prime or a unique product of primes (fundamental theorem of arithmetic), two words are anagrams if their products are the same.
-- From https://twitter.com/fermatslibrary/status/875340896379817984
Examples
extern crate is_anagram; use is_anagram::IsAnagram; assert!("banana".is_anagram_of("nabana").unwrap()); assert!(!"lorem".is_anagram_of("ipsum").unwrap());
Structs
Error |
The Error type. |
Traits
IsAnagram |