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

Lint using |_| () instead of drop #2523

Open
clarfon opened this issue Mar 13, 2018 · 4 comments

Comments

Projects
None yet
5 participants
@clarfon
Copy link
Contributor

commented Mar 13, 2018

Basically, any occurrence of |_| () as a closure could be more clearly worded as drop.

@birkenfeld

This comment has been minimized.

Copy link
Collaborator

commented Mar 16, 2018

I don't agree. To me, drop signals that the important point is to destroy the value while |_| () says that the important point is to ignore it. Especially with a primitive type like an integer, it'd be a "huh?" moment.

@clarfon

This comment has been minimized.

Copy link
Contributor Author

commented Mar 16, 2018

@birkenfeld Do you have a good example of a case like that?

Something like Some(5).map(|_| ()) makes more sense as Some(5).map(drop) to me.

@CryZe

This comment has been minimized.

Copy link

commented Apr 17, 2019

drop is definitely much more readable imo and other people seem to be confused by "the toilet closure" too: https://www.reddit.com/r/rust/comments/bdqxch/actixweb_what_map_err_is_really_doing/

@Manishearth

This comment has been minimized.

Copy link
Member

commented Apr 17, 2019

I don't find drop to be readable in an error context. The toilet closure is confusing too, but at least it's become a norm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.