You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I know this has been already discussed in #5, but it's been 8 years so i hope you don't mind me bringing this up again.
In many, if not most cases, where i'm using walkdir, i need the path relative to the root. For example, below is a naive recursive directory copy implementation, but this also applies to anything that needs to do includes or excludes with non-absolute matchers.
Currently, entry.path() does not seem to guarantee that the path starts with the walkdir root (or at least i didn't see that in the docs), the the unwrap could potentially fail, even if i know that i should be able to write code that never fails here.
From an API-perspective, it would be nice to have an infallible .relative_path(). Currently, there are usually two let relative = entry.path().strip_prefix(source_tree).expect("walkdir starts with root"); invocations when i call walkdir, one for filter_entry and one in the for loop body. This API would expose the infallible operation as such and could slim multi-line .filter_entry calls to a single line of .filter_entry(|entry| matches_directory(entry.relative_path()).
I know this has been already discussed in #5, but it's been 8 years so i hope you don't mind me bringing this up again.
In many, if not most cases, where i'm using walkdir, i need the path relative to the root. For example, below is a naive recursive directory copy implementation, but this also applies to anything that needs to do includes or excludes with non-absolute matchers.
Currently,
entry.path()
does not seem to guarantee that the path starts with the walkdir root (or at least i didn't see that in the docs), the the unwrap could potentially fail, even if i know that i should be able to write code that never fails here.From an API-perspective, it would be nice to have an infallible
.relative_path()
. Currently, there are usually twolet relative = entry.path().strip_prefix(source_tree).expect("walkdir starts with root");
invocations when i call walkdir, one forfilter_entry
and one in the for loop body. This API would expose the infallible operation as such and could slim multi-line.filter_entry
calls to a single line of.filter_entry(|entry| matches_directory(entry.relative_path())
.The text was updated successfully, but these errors were encountered: