Converting a binary string to hexadecimal using Rust
A couple of things:


Any time you have a function which could fail, it should return an Option&lt;T&gt;.  Ask yourself, if someone calls convert_to_hex_from_binary("foobar") and gets back "", is that reasonable?  They will need to manually check that their input makes sense, or that the output makes sense every time.  Static checking of these errors is part of the joy of Rust. 


With that it mind, change to_hex like so:

fn to_hex(b: &amp;str) -&gt; Option&lt;&amp;str&gt; {
    match b {
        "0000" =&gt; Some("0"),
        "0001" =&gt; Some("1"),
        "0010" =&gt; Some("2"),
        "0011" =&gt; Some("3"),
        "0100" =&gt; Some("4"),
        "0101" =&gt; Some("5"),
        "0110" =&gt; Some("6"),
        "0111" =&gt; Some("7"),
        "1000" =&gt; Some("8"),
        "1001" =&gt; Some("9"),
        "1010" =&gt; Some("A"),
        "1011" =&gt; Some("B"),
        "1100" =&gt; Some("C"),
        "1101" =&gt; Some("D"),
        "1110" =&gt; Some("E"),
        "1111" =&gt; Some("F"),
        _ =&gt; None,
    }
}



You are iterating over a known range of values to get counter.  Instead of using a while loop, you can use a range.  Since you're now returning None from to_hex you can now shortcut returning if something is wrong with None.


Your inner loop now looks like this:

let mut hex_string = String::new();
for counter in (0..padded_binary.len()).step_by(4) {
    match to_hex(&amp;padded_binary[counter..counter + 4])
    {
        Some(converted) =&gt; hex_string.push_str(converted),
        None =&gt; return None
    };
}


Your function signature and return type also need to match Option&lt;String&gt;:

fn convert_to_hex_from_binary(binary: &amp;str) -&gt; Option&lt;String&gt; {
    ...
    Some(hex_string)
}



Your padded_binary definition can be simplified, since repeating "0" zero times is exactly the same as not repeating it.


The definition is simply:

let padded_binary = ["0".repeat(padding_count), binary.to_string()].concat();


A couple of non Rust specific things:


Consider writing some tests.
String representation of binary numbers often begin with '0b'.  For example 0b1101 == 13.  You might want to consider checking for this prefix on the input string and trimming it.
You may have already thought about this, but consider if you want to trim whitespace or leave it to the function caller.