Commit Graph

142 Commits

Author SHA1 Message Date
Taiki Endo
360432f1e8 libcore => 2018 2019-04-18 14:47:35 +09:00
Vincent Esche
698bbe5253 Replaced self-reflective explicit types with clearer Self or Self::… in stdlib docs 2019-03-18 13:57:51 +01:00
Simon Sapin
3906cb9187 Stabilize iter::from_fn
FCP: https://github.com/rust-lang/rust/issues/55977#issuecomment-463964234
2019-02-19 14:10:07 +01:00
Simon Sapin
95d2795907 Stabilize iter::successors
FCP: https://github.com/rust-lang/rust/issues/58045#issuecomment-464674773
2019-02-19 13:58:55 +01:00
Simon Sapin
61e92b586b Rename iter::unfold to iter::from_fn and remove explicit state
This API is unstable.

CC https://github.com/rust-lang/rust/issues/55977#issuecomment-459657195
2019-02-01 23:59:11 +01:00
Clar Fon
5971ccc08d Don't expose ZipImpl to Iterator 2019-01-22 17:45:11 -05:00
Clar Fon
53b400c30c Don't expose FlattenCompat to Iterator 2019-01-22 17:45:11 -05:00
Clar Fon
7e4177311a Don't expose ChainState to Iterator 2019-01-22 17:45:11 -05:00
Clar Fon
520e8b001e Move TrustedRandomAccess into Zip module 2019-01-22 17:45:11 -05:00
Clar Fon
c40450ce65 Move core::iter iterator.rs to traits module 2019-01-22 17:45:11 -05:00
Clar Fon
aff7772a1d Move core::iter adapters to adapters.rs 2019-01-22 17:45:10 -05:00
Mazdak Farrokhzad
ae1ab8afa9
Rollup merge of #57579 - stjepang:once-with, r=SimonSapin
Add core::iter::once_with()

Functions `iter::once()` and `iter::repeat()` construct iterators from values. The latter has the lazy variant `iter::repeat_with()`, but the former doesn't. This PR therefore adds `iter::once_with()`.

Another way to think of `iter::once_with()` is that it's a function that converts `FnOnce() -> T` into `Iterator<Item = T>`.

If this seems like a reasonable addition, I'll open a tracking issue and update the `#[feature(...)]` attributes.
2019-01-15 12:42:10 +01:00
Stjepan Glavina
7915732714 Fix intradoc link and update issue number 2019-01-13 21:24:15 +01:00
Stjepan Glavina
04c74f46f0 Add core::iter::once_with 2019-01-13 16:58:08 +01:00
Taiki Endo
da933cca1a Change #[must_use] message of Iterator in documentation 2019-01-13 15:17:57 +09:00
Taiki Endo
a6535d78dc Change #[must_use] message of Iterator 2019-01-13 14:46:42 +09:00
bors
a7be40c65a Auto merge of #56534 - xfix:copied, r=@SimonSapin
Add unstable Iterator::copied()

Initially suggested at https://github.com/bluss/rust-itertools/pull/289, however the maintainers of itertools suggested this may be better of in a standard library.

The intent of `copied` is to avoid accidentally cloning iterator elements after doing a code refactoring which causes a structure to be no longer `Copy`. This is a relatively common pattern, as it can be seen by calling `rg --pcre2 '[.]map[(][|](?:(\w+)[|] [*]\1|&(\w+)[|] \2)[)]'` on Rust main repository. Additionally, many uses of `cloned` actually want to simply `Copy`, and changing something to be no longer copyable may introduce unnoticeable performance penalty.

Also, this makes sense because the standard library includes `[T].copy_from_slice` to pair with `[T].clone_from_slice`.

This also adds `Option::copied`, because it makes sense to pair it with `Iterator::copied`. I don't think this feature is particularly important, but it makes sense to update `Option` along with `Iterator` for consistency.
2018-12-26 19:39:19 +00:00
Konrad Borowski
315401ddf8 Add a tracking issue for Iterator::copied 2018-12-26 10:13:44 +01:00
Mark Rousskov
2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
Konrad Borowski
8ac5380ea0
Merge branch 'master' into copied 2018-12-23 16:47:11 +01:00
Clar Fon
fb18ddaaaa Add DoubleEndedIterator::nth_back 2018-12-20 01:18:04 -05:00
Shotaro Yamada
f0483f76e6 Remove <Cycle as Iterator>::try_fold override
It was a incorrect optimization.
2018-12-17 15:00:22 +09:00
Shotaro Yamada
5728a043e8 Don't call size_hint of underlying iterator needlessly 2018-12-09 00:01:09 +09:00
Shotaro Yamada
e704ce9e8a Resolve FIXME and cleanup 2018-12-09 00:01:09 +09:00
Shotaro Yamada
fbe5aa57ed Override Cycle::try_fold
name                            old ns/iter  new ns/iter  diff ns/iter   diff %  speedup
 iter::bench_cycle_take_ref_sum  927,152      927,194                42    0.00%   x 1.00
 iter::bench_cycle_take_sum      938,129      603,492          -334,637  -35.67%   x 1.55
2018-12-09 00:01:09 +09:00
Konrad Borowski
b4a306c1e6 Avoid calling clone in DoubleEndedIterator implementation of Copied 2018-12-05 17:55:53 +01:00
Konrad Borowski
3eddc743f2 Use inner iterator may_have_side_effect for Cloned
Previous implementation wasn't correct, as an inner iterator
could have had side effects.
2018-12-05 16:48:34 +01:00
Konrad Borowski
431968df37 Copy may_have_side_effect from I for Copied<I> 2018-12-05 16:42:20 +01:00
Konrad Borowski
3ee0747b5a Use copied method instead of cloned in Copied::next_back() 2018-12-05 16:37:55 +01:00
Konrad Borowski
ab2cd6070e Add unstable Iterator::copied() 2018-12-05 15:40:14 +01:00
Simon Sapin
a4279a07e2 Capitalize 2018-11-20 18:22:40 +01:00
Simon Sapin
8a5bbd9a4e Add tracking issue for unfold and successors 2018-11-20 18:22:40 +01:00
Simon Sapin
641c4909e4 Add std::iter::successors 2018-11-20 18:22:40 +01:00
Simon Sapin
48aae09e9f Add std::iter::unfold 2018-11-20 18:22:40 +01:00
Артём Павлов [Artyom Pavlov]
126b71f690
revert 2018-11-18 21:39:23 +03:00
varkor
f5b89062f6 Unused result warning: "X which must" ↦ "X that must" 2018-10-14 18:25:30 +01:00
Aleksey Kladov
1a0d3f0979 Fix since of Iterator::flatten to be a proper semver 2018-08-15 19:28:42 +03:00
kennytm
6093128ef3
Changed implementation of the third field to make LLVM optimize it better. 2018-07-13 13:26:07 +08:00
kennytm
b6ea93e464
Upgrade implementation of StepBy<RangeInclusive<_>>. 2018-07-13 09:53:37 +08:00
Pietro Albini
0f8343830b
Rollup merge of #51511 - Centril:feature/stabilize_iterator_flatten, r=SimonSapin
Stabilize Iterator::flatten in 1.29, fixes #48213.

This PR stabilizes [`Iterator::flatten`](https://doc.rust-lang.org/nightly/std/iter/trait.Iterator.html#method.flatten) in *version 1.29* (1.28 goes to beta in 10 days, I don't think there's enough time to land it in that time, but let's see...).

Tracking issue is:  #48213.

cc @bluss re. itertools.
r? @SimonSapin
ping @pietroalbini -- let's do a crater run when this passes CI :)
2018-07-01 21:18:43 +02:00
Emerentius
000aff604e specialize StepBy<Range(Inclusive)>
the originally generated code was highly suboptimal
this brings it close to the same code or even exactly the same as a
manual while-loop by eliminating a branch and the
double stepping of n-1 + 1 steps

The intermediate trait lets us circumvent the specialization
type inference bugs
2018-06-19 19:33:54 +02:00
kennytm
8ae188959b
Replace core::iter::AlwaysOk<T> by Result<T, !> 2018-06-13 06:54:31 +08:00
Mazdak Farrokhzad
85796dd0ba stabilize Iterator::flatten in 1.29, fixes #48115. 2018-06-11 23:10:51 +02:00
bors
c5a129e809 Auto merge of #51200 - tmccombs:stable-iter-repeat-with, r=Centril,kennytm
Stabilize iterator_repeat_with

Fixes #48169
2018-06-10 15:48:14 +00:00
Thayne McCombs
72e17b81fa Stabilize Iterator::step_by
Fixes #27741
2018-06-02 20:42:42 -06:00
Thayne McCombs
87941b079a Stabilize iterator_repeat_with
Fixes #48169
2018-06-02 15:52:09 -06:00
Niv Kaminer
7278e37d38 update FIXME(#6393) to point to issue 43234 (tracking issue for non-lexical lifetimes) 2018-03-17 20:24:27 +02:00
Mazdak Farrokhzad
6fbdaf4209 unstabilize FusedIterator for Flatten since Flatten is unstable 2018-03-15 18:04:45 +01:00
Ulrik Sverdrup
c7c23fe948 core: Update stability attributes for FusedIterator 2018-03-03 14:23:05 +01:00
Ulrik Sverdrup
bc651cac8d core: Stabilize FusedIterator
FusedIterator is a marker trait that promises that the implementing
iterator continues to return `None` from `.next()` once it has returned
`None` once (and/or `.next_back()`, if implemented).

The effects of FusedIterator are already widely available through
`.fuse()`, but with stable `FusedIterator`, stable Rust users can
implement this trait for their iterators when appropriate.
2018-03-03 14:14:03 +01:00