-
Notifications
You must be signed in to change notification settings - Fork 13k
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
iter: decide on the fate of to_owned_vec, sum and product #9496
Comments
(Unfortunately marking them with a stability is blocked on #8961.) |
I'm not sure if it's a solution if I think the specialized method is the pragmatic solution, but would it be wrong to look towards something completely different? Say standardizing on |
@blake2-ppc That's basically Also, I personally find i much harder to parse nested function calls like that than to chain a method, so I'd be against removing that in general.
|
@blake2-ppc: It's an extra redundant method for every container to implement and only I'm strongly against including these methods, and also strongly against duplicating trait static methods in the type namespace. Working around language flaws by adding duplicate functions/methods all over the place is awful. I almost regret adding the |
What would the alternative to A thought: A trait doesn't have to be a user-facing interface and vice versa. |
Generic conversion from iterators is important, and I am definitely against the usual pattern of duplicating code everywhere. |
oh yeah. In my mind |
Yeah, I expect |
I'm okay with keeping |
[`never_loop`]: Fix FP with let..else statements. Fixes rust-lang#9356 This has been bugging me for a while, so I thought I'd take a stab at it! I'm completely uncertain about the quality of my code, but I think it's an alright start, so opening this PR to get some feedback from more experienced clippy people :) changelog: [`never_loop`]: Fix FP with let..else statements
The
sum
andproduct
methods are wrappers aroundfold
, but only work with iterators where the element typeA
directly implementsAdd<A, A>
/Mul<A, A>
. With an iterator of references to numbers, you can doiter().fold(0, |a, b| a + *b)
, but withsum
/product
the elements have to be cloned viamap
(inefficient for big integers, and uglier than usingfold
).The
to_owned_vec
method simply callscollect
, and removes the need to specify a type annotation. It's the only method on iterators using a specific container type, which is ugly. A language solution to this problem (partial type hints?collect::<~[_]>()
) would be nice.These are good candidates for being marked with a stability warning attribute.
The text was updated successfully, but these errors were encountered: