Closed nvzqz closed 5 years ago
These impls seem a touch weird to me, but I don't feel strongly. What is the motivating use case for these?
My main motivation is that a new PathBuf
gets allocated if one gets passed into WalkDir::new
. This allows for using an existing allocation.
Do you have a real benchmark that shows this one particular allocation matters? The rest of the implementation is careful with allocation, but there is definitely plenty more of it. I have a hard time believing that the removal of one allocation matters here, particularly when there are many other allocations and syscalls.
No I do not. It just stood out to me as odd that there wasn't an efficient way to pass a buffer without creating a new one.
I don't think these are out of place, however. It's common for types to have From
implementations that are symmetrical to what can be passed into new
.
I think I'd rather hold off on taking these impls for now until we can come up with more compelling motivation for them. (e.g., A benchmark or specific use case.)
Allows for creating a
WalkDir
from an existingPathBuf
without allocating and copying from aPath
slice.Also added
From<&Path>
for consistency withWalkDir::new
.