-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Suggest replacing .map(f).flatten() with .and_then(f) on Options #6870
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
Comments
Do you mean this case? rust-clippy/tests/ui/map_flatten.stderr Lines 33 to 39 in 4c8d248
|
Ah, so I did! The description in the docs made me think it's only for |
Which means the description should be fixed, right? |
Yes, I think so. I will prepare a fix. |
Thanks, @giraffate! |
Hmm, this doesn't seem to be working: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=d9855ae1539cc222b88fa4baa7b46b92 let _: Option<&str> = x.as_ref().map(|pb| pb.to_str()).flatten(); doesn't get a warning. |
@jyn514 It’s a pedantic lint; not enabled by default. |
Ah ok, that makes sense. What do you think about making it a style lint instead? |
Seems reasonable to me to have it be a style lint. I’m not really sure I understand the distinction anyways; I see a lot of similar types of lints on both sides of the distinction, e.g. More pedantic lints other than |
I think this should be a style lint too. I didn't know about this lint until I figure out I can use |
What it does
What does this lint do?
Checks for usage of
_.map(_).flatten()
,This is like https://rust-lang.github.io/rust-clippy/master/index.html#map_flatten but for
Option
s instead ofIterator
sCategories (optional)
Easier to follow what's happening, shorter
Drawbacks
None.
Example
Inspired by @steffahn's suggestion in Nadrieril/dhall-rust#213 (comment)
The text was updated successfully, but these errors were encountered: