Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Clone for WalkDir #78

Closed
wants to merge 1 commit into from
Closed

Implement Clone for WalkDir #78

wants to merge 1 commit into from

Conversation

laumann
Copy link

@laumann laumann commented Aug 4, 2017

Fixes #54

I tried out @BurntSushi's suggestion to use Arc and it seems to work.

Copy link
Owner

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

@laumann
Copy link
Author

laumann commented Aug 4, 2017

np :-) My only worry is the unwrap()- could that cause any problems, do you think?

@BurntSushi
Copy link
Owner

@laumann Oh! Thanks so much for pointing that out, I completely missed that. Yeah, we definitely can't do that. Which means you can't borrow the function mutably, which in turn means you can't call it. So we have three choices:

  1. Turn FnMut into Fn.
  2. Use Arc<Mutex<FnMut(...)>> instead of Arc<FnMut(...)>.
  3. Don't make WalkDir cloneable.

I'm inclined to go with option (3) for a variety of reasons that have kind of already been hashed out. That is, we want calls to be able to do mutation inside the closure, and adding the overhead of a mutex to the sorting function isn't acceptable I think. So I think this PR can be closed. :-(

Copy link
Owner

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See other comment.

@laumann
Copy link
Author

laumann commented Aug 4, 2017

That's OK. It seemed so simple... :-)

@laumann laumann closed this Aug 4, 2017
@laumann laumann deleted the walkdir-impl-clone branch August 4, 2017 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants