stdlib: Use if/alt expressions in std::fs

This commit is contained in:
Brian Anderson 2011-05-20 20:55:59 -04:00
parent 85bcf75da1
commit da0e961f61

View File

@ -22,10 +22,11 @@ fn dirname(path p) -> path {
// FIXME: Need some typestate to avoid bounds check when len(pre) == 0
fn connect(path pre, path post) -> path {
auto len = str::byte_len(pre);
if (pre.(len - 1u) == (os_fs::path_sep as u8)) { // Trailing '/'?
ret pre + post;
}
ret pre + path_sep() + post;
ret if (pre.(len - 1u) == (os_fs::path_sep as u8)) { // Trailing '/'?
pre + post
} else {
pre + path_sep() + post
};
}
fn file_is_dir(path p) -> bool {