Writing slice compare in a more compact way
What about this:

fn compare(a: &amp;[u8], b: &amp;[u8]) -&gt; cmp::Ordering {
    for (ai, bi) in a.iter().zip(b.iter()) {
        match ai.cmp(&amp;bi) {
            Ordering::Equal =&gt; continue,
            ord =&gt; return ord
        }
    }

    /* if every single element was equal, compare length */
    a.len().cmp(&amp;b.len())
}


I've removed the self argument, and used the cmp-module to do the actual comparison and zip() as @alexv already suggested.