-
Notifications
You must be signed in to change notification settings - Fork 1.7k
lint flat_map into filter_map #2241
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Eh, quick question: Why not just use (Yes, I like to abuse flat_map and the Iterator impls on these types.) (And here comes the usual E-hard suggestion: Write a lint that detects unnecessary method calls, like the |
IMO now that |
You can't change the signatures of trait methods upstream
…On Dec 2, 2017 8:16 AM, "Clar Roʒe" ***@***.***> wrote:
IMO now that Try is stable, upstream should replace filter_map with a
version that uses Try instead. That would allow use of Result as well as
option.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2241 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABivSMYiE44RuNJHm0KXBTX95KNIyWbEks5s8XfUgaJpZM4Qln-C>
.
|
...right, that's correct. :/ |
you can if it's generic and strictly allows more code |
I'm talking about trait methods. You can do that with inherent methods.
This is a trait you can implement yourself. Most don't override flat_map,
but they *can*, so we can't change this.
On Dec 2, 2017 12:46 PM, "Oliver Schneider" <notifications@github.com> wrote:
You can't change the signatures of trait methods upstream
you can if it's generic and strictly allows more code
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2241 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABivSHplrdiuK78_AMLvFh04hzmkVgLuks5s8bcOgaJpZM4Qln-C>
.
|
I mean, they could always do a crater run to check. Although at the moment, isn't |
No, that's not one of the "allowed" kinds of breakages.
Crater is not a carte blanche to make breaking changes.
There's a set of allowed breaking changes. We still do crater runs for
those.
Additionally for fixing bugs and soundless issues we are allowed to make
otherwise-disallowed breakages with a crater run, but this is not a biggie.
…On Dec 2, 2017 1:01 PM, "Clar Roʒe" ***@***.***> wrote:
I mean, they *could* always do a crater run to check. Although at the
moment, isn't FilterMap literally coded as a façade over FlatMap, or am I
wrong?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2241 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABivSG7ciDup5LRK6DdPEEysO_MpI_2aks5s8bqzgaJpZM4Qln-C>
.
|
|
One thing we could lint is manually constructing one-element- |
filter_map
is a more specific version offlat_map
. It would be neat if Clippy recommended usingfilter_map
instead offlat_map
when the function inflat_map
returnsOption
.This is an example from documentation with
filter_map
replaced byflat_map
.it would be more readable with
filter_map
instead offlat_map
.The text was updated successfully, but these errors were encountered: