Convert string of hex into vector of bytes
Note that this code will not work on any non-ASCII strings. These are more and more common, especially considering the global community we are a part of (and don't forget emoji ).
Use Vec&lt;_&gt; to avoid redundantly specifying the inner type when collecting.
Use byte literals b'x' instead of casting characters to bytes.
You can match on ranges of characters. I find this aesthetically pleasing.
Don't collect an iterator into a Vec just to call into_iter on the Vec. Instead, use the original iterator with partition.
Don't convert from u8 to char and back. You only need to make a single transformation.
There's no need to use the turbofish with the final collect since it's being returned and the type can be inferred.
There's no need to call into_iter for zip's argument, it's implied because it takes an IntoIterator.
Instead of partitioning into vectors, just grab two values out of the iterator at a time. Using fuse allows calling next after it's already returned None.
Your code handles the check of a hex digit twice, leading to the unreachable. Instead, perform the conversion when performing the check.




fn parse_hex(hex_asm: &amp;str) -&gt; Vec&lt;u8&gt; {
    let mut hex_bytes = hex_asm.as_bytes().iter().filter_map(|b| {
        match b {
            b'0'...b'9' =&gt; Some(b - b'0'),
            b'a'...b'f' =&gt; Some(b - b'a' + 10),
            b'A'...b'F' =&gt; Some(b - b'A' + 10),
            _ =&gt; None,
        }
    }).fuse();

    let mut bytes = Vec::new();
    while let (Some(h), Some(l)) = (hex_bytes.next(), hex_bytes.next()) {
        bytes.push(h &lt;&lt; 4 | l)
    }
    bytes
}