scottmcm

Results 253 comments of scottmcm

I would expect that `.cloned().cloned()` is just as efficient -- maybe even *more* efficient since it's using core methods which could have some fancy internal optimizations.

Related: https://github.com/rust-lang/rust/pull/76234

> It defines a new safe wrapper around [T;N] which starts out uninitialised and can be filled up safely, also implementing drop. This is one of those things that it...

Note that if you want `collect_array`, you can use https://lib.rs/crates/arrayvec, as the usual way to collect into an array. I'll also mention [`Iterator::next_chunk`](https://doc.rust-lang.org/nightly/std/iter/trait.Iterator.html#method.next_chunk) (https://github.com/rust-lang/rust/issues/98326) as a nightly API that'll be...

Hmm, is it really best to have an `_ok` version of just about everything? Are these scenarios where it might be better to use something like https://docs.rs/fallible-iterator/0.2.0/fallible_iterator/trait.FallibleIterator.html that's specifically for...

Hmm, `Itertools` has similar functionality, but it groups it differently. For example, it has `merge_join_by(...).filter_map(EitherOrBoth::both)`, which is essentially an inner join, albeit one that cares about cardinality differently from how...

Can you say more about why this would be useful to you? I feel like I'd most often *want* the compiler error here, because if I'm using `next_tuple` I'm expecting...

> This assumes the iterator is a FusedIterator, does it not? I think we need to call .fuse() first? Or skip the `for_each` if `heap.len() < k`.

Because of the potential for overflow, it's not actually correct to implement `ExactSizeIterator` for any adapter that makes an iterator longer -- you'll notice that [`Chain`](https://doc.rust-lang.org/stable/std/iter/struct.Chain.html) doesn't implement it either.

It's available on nightly if anyone wants to try an experiment to see what it would look like: https://doc.rust-lang.org/nightly/std/ops/enum.ControlFlow.html (I agree with waiting for it to stabilize before merging such...