Simplify a Unix-style absolute path I have a match arm in rust, I think it may be simplified, but after googling and read books, I haven't find the solution. Especially for the str_vec.pop(), it returns an option type, I have to write a meanless () to make it compileable.
pub fn simplify_path(path: &amp;String) -&gt; String {
    let mut str_vec: Vec&lt;&amp;str&gt; = Vec::with_capacity(20);
    for line in path.split('/') {
        match line {
            &quot;&quot; | &quot;.&quot; =&gt; {}
            &quot;..&quot; =&gt; {
                str_vec.pop();
                ()
            }
            _ =&gt; str_vec.push(line),
        }
    }

    &quot;/&quot;.to_string() + &amp;str_vec.join(&quot;/&quot;)
}
The () is not needed in this example - the following example compiles fine.
match line {
    &quot;&quot; | &quot;.&quot; =&gt; {}
    &quot;..&quot; =&gt; {
        str_vec.pop();
    }
    _ =&gt; str_vec.push(line),
}

This is as all arms need to return the same type, and in this case it is the type (). Luckily this type is inferred, and as such you can just make a block and (as long as it doesn't return anything), it will be inferred that the () type is being returned instead.
I would recommend making some other changes to your code though - namely changing the &amp;String argument to &amp;str, which can improve performance in some cases and allow more string types (such as a string literal) to be passed to the function. This type of issue can be picked up by running clippy, which also picks up a wide variety of issues - a full list can be found at https://rust-lang.github.io/rust-clippy/master/.