Created
October 27, 2015 17:27
-
-
Save thommay/22eb052ee372fe1b4cc8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Remove duplicate and trailing slashes from a path | |
fn squeeze_path(pth: String) -> String { | |
let mut st = String::new(); | |
for p in pth.split('/').filter(|&x| x != "") { | |
st.push('/'); | |
st.push_str(p) | |
} | |
if st.len() == 0 { | |
String::from("/") | |
} else { | |
st | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment