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 hit a snag with lifetimes and wondered: is it intentional that WalkDir.sort_by_key requires a 'static lifetime on its func argument instead of just the same lifetime as the WalkDir?
I was trying to do something like this:
let walker = WalkDir::new(path).sort_by_key(|e| {let relative_path = e.path().strip_prefix(path).unwrap();some_func(relative_path)})
…
and that failed saying my path didn't live long enough for the required 'static lifetime, even though it does live until after walker was used and dropped.
The text was updated successfully, but these errors were encountered:
I would suggest putting path into an Arc. Either that, or just cloning it and moving it into the closure. Either should be marginal costs relative to recursive directory traversal.
I hit a snag with lifetimes and wondered: is it intentional that
WalkDir.sort_by_key
requires a'static
lifetime on its func argument instead of just the same lifetime as the WalkDir?I was trying to do something like this:
and that failed saying my
path
didn't live long enough for the required'static
lifetime, even though it does live until afterwalker
was used and dropped.The text was updated successfully, but these errors were encountered: