Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,18 @@ impl PathClean for PathBuf {
/// 5. Leave intact `..` elements that begin a non-rooted path.
///
/// If the result of this process is an empty string, return the string `"."`, representing the current directory.
#[inline]
pub fn clean<P>(path: P) -> PathBuf
where
P: AsRef<Path>,
{
clean_impl(path.as_ref())
}

fn clean_impl(path: &Path) -> PathBuf {
let mut out = Vec::new();

for comp in path.as_ref().components() {
for comp in path.components() {
match comp {
Component::CurDir => (),
Component::ParentDir => match out.last() {
Expand Down