about summary refs log tree commit diff
path: root/src/libcore/iter.rs
AgeCommit message (Collapse)AuthorLines
2015-03-23Add #![feature] attributes to doctestsBrian Anderson-2/+20
2015-03-17std: Stabilize `IteratorExt::cloned`Alex Crichton-27/+18
This commit stabilizes the `cloned` iterator after tweaking the signature to require that the iterator is over `&T` instead of `U: Deref<T>`. This method has had time to bake for awhile now and it's not clear whether the `Deref` bound is worth it. Additionally, there aren't clear conventions on when to bound and/or implement the `Deref` trait, so for now the conservative route is to require references instead of `U: Deref<T>`. To change this signature to using `Deref` would technically be a backwards-incompatible change, but it is doubtful that any code will actually break in practice.
2015-03-13Deprecate range, range_step, count, distributionsAaron Turon-69/+113
This commit deprecates the `count`, `range` and `range_step` functions in `iter`, in favor of range notation. To recover all existing functionality, a new `step_by` adapter is provided directly on `ops::Range` and `ops::RangeFrom`. [breaking-change]
2015-03-12Rollup merge of #23247 - tbu-:pr_core_iter_rm_isize, r=huonwManish Goregaokar-3/+3
2015-03-11Example -> ExamplesSteve Klabnik-1/+1
This brings comments in line with https://github.com/rust-lang/rfcs/blob/master/text/0505-api-comment-conventions.md#using-markdown
2015-03-10Purge `isize` from `core::iter`Tobias Bucher-3/+3
2015-03-08Add description of fold function arguments.Łukasz Niemier-1/+1
2015-03-06Rollup merge of #23025 - huonw:better-iter-infer, r=GankroManish Goregaokar-46/+48
This concretely improves type inference of some cases (see included test). I assume the compiler struggles to reason about multiple layers of generic type parameters (even with associated-type equalities) but *can* understand pure associated types, since they are always directly computable from the input types. Thanks to @shepmaster for noticing the issue with `Cloned` (I took that example as a test case).
2015-03-05Use more associated types in core::iter.Huon Wilson-46/+48
This concretely improves type inference of some cases (see included test). I assume the compiler struggles to reason about multiple layers of generic type parameters (even with associated-type equalities) but *can* understand pure associated types, since they are always directly computable from the input types.
2015-03-05Remove integer suffixes where the types in compiled code are identical.Eduard Burtescu-1/+1
2015-03-04Auto merge of #22958 - laijs:option_map_for_iter_map, r=alexcrichtonbors-16/+3
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
2015-03-03Auto merge of #22532 - pnkfelix:arith-overflow, r=pnkfelix,eddybbors-3/+8
Rebase and follow-through on work done by @cmr and @aatch. Implements most of rust-lang/rfcs#560. Errors encountered from the checks during building were fixed. The checks for division, remainder and bit-shifting have not been implemented yet. See also PR #20795 cc @Aatch ; cc @nikomatsakis
2015-03-03Rollup merge of #22952 - huonw:missing-stable, r=alexcrichtonManish Goregaokar-0/+2
Unstable is the conservative choice. cc #22950.
2015-03-03`core::iter`: fix bug uncovered by arith-overflow.Felix S. Klock II-1/+5
(The bug was in `impl RandomAccessIterator for Rev`; it may or may not have been innocuous, depending on what guarantees one has about the behavior of `idx` for the underlying iterator.)
2015-03-03fix Iter::rposition for new arith-overflow checking.Felix S. Klock II-2/+3
2015-03-02core: Audit num module for int/uintBrian Anderson-3/+3
* count_ones/zeros, trailing_ones/zeros return u32, not usize * rotate_left/right take u32, not usize * RADIX, MANTISSA_DIGITS, DIGITS, BITS, BYTES are u32, not usize Doesn't touch pow because there's another PR for it. [breaking-change]
2015-03-02iter: use Option::map() in struct Iterater::map()Lai Jiangshan-16/+3
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
2015-03-02Add missing stability attributes on struct fields.Huon Wilson-0/+2
Unstable is the conservative choice. cc #22950.
2015-03-01Auto merge of #22898 - edwardw:one-less-unsafe-impl, r=huonwbors-5/+1
These implementations were temporary workaround. Now #22828 has been fixed, they can be removed.
2015-02-28Remove two unsafe impls from `iter::Peekable`Edward Wang-5/+1
These implementations were temporary workaround. Now #22828 has been fixed, they can be removed.
2015-02-28Update iter::order to be more generic.JP-Ellis-34/+20
Signed-off-by: JP-Ellis <coujellis@gmail.com>
2015-02-27Rollup merge of #22848 - tshepang:redundant-mention, r=brsonManish Goregaokar-2/+1
2015-02-27Rollup merge of #22833 - laijs:remove-redundant-else-branch, r=dotdashManish Goregaokar-2/+0
The branch \"else { continue }\" is the last code inside a loop body, it is just useless. Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
2015-02-27Rollup merge of #22795 - alexcrichton:issue-22617, r=huonwManish Goregaokar-2/+2
Keeps the method consistent with `Iterator::any`. Closes #22617 [breaking-change]
2015-02-26doc: the last mention of the word 'iterator' is redundantTshepang Lekhonkhobe-2/+1
2015-02-26remove the redundant else branchLai Jiangshan-2/+0
The branch "else { continue }" is the last code inside a loop body, it is just useless. Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
2015-02-26Send/Sync audit for libcollectionsEdward Wang-1/+5
In the process, also replaces a raw mutable pointers with Unique to spell out the ownership semantics. cc #22709
2015-02-24std: Require `&mut self` for Iterator::allAlex Crichton-2/+2
Keeps the method consistent with `Iterator::any`. Closes #22617 [breaking-change]
2015-02-25Rollup merge of #22635 - kmcallister:macros-chapter, r=steveklabnikManish Goregaokar-1/+1
r? @steveklabnik
2015-02-24Use arrays instead of vectors in testsVadim Petrochenkov-2/+2
2015-02-24core: fix typo that wasn't caught by the hacky previous implementation.Eduard Burtescu-1/+1
2015-02-23Add documentation to associated types in libcore, libstdIvan Petkov-0/+3
2015-02-20Add examples for iter::range_stepSteve Klabnik-2/+47
2015-02-18rollup merge of #22286: nikomatsakis/variance-4bAlex Crichton-5/+6
Conflicts: src/librustc/middle/infer/combine.rs src/librustc_typeck/check/wf.rs
2015-02-18Round 1 fixes and rebase conflictsAlex Crichton-5/+5
2015-02-18rollup merge of #22491: Gankro/into_iterAlex Crichton-3/+3
Conflicts: src/libcollections/bit.rs src/libcollections/linked_list.rs src/libcollections/vec_deque.rs src/libstd/sys/common/wtf8.rs
2015-02-18rollup merge of #22287: Ryman/purge_carthographersAlex Crichton-5/+22
This overlaps with #22276 (I left make check running overnight) but covers a number of additional cases and has a few rewrites where the clones are not even necessary. This also implements `RandomAccessIterator` for `iter::Cloned` cc @steveklabnik, you may want to glance at this before #22281 gets the bors treatment
2015-02-18make FromIterator use IntoIteratorAlexis-2/+2
This breaks all implementors of FromIterator, as they must now accept IntoIterator instead of Iterator. The fix for this is generally trivial (change the bound, and maybe call into_iter() on the argument to get the old argument). Users of FromIterator should be unaffected because Iterators are IntoIterator. [breaking-change]
2015-02-18make Extend use IntoIteratorAlexis-1/+1
This breaks all implementors of Extend, as they must now accept IntoIterator instead of Iterator. The fix for this is generally trivial (change the bound, and maybe call into_iter() on the argument to get the old argument). Users of Extend should be unaffected because Iterators are IntoIterator. [breaking-change]
2015-02-18Fallout: iter, add markers or other changes such that all type parameters ↵Niko Matsakis-5/+6
are used.
2015-02-17Register new snapshotsAlex Crichton-23/+0
2015-02-17rollup merge of #22454: alexcrichton/stabilize-into-iteratorAlex Crichton-0/+5
Now that the necessary associated types exist for the `IntoIterator` trait this commit stabilizes the trait as-is as well as all existing implementations.
2015-02-18Remove usage of .map(|&foo| foo)Kevin Butler-4/+4
2015-02-18Opt for .cloned() over .map(|x| x.clone()) etc.Kevin Butler-1/+1
2015-02-18Implement RandomAccessIterator for ClonedKevin Butler-0/+17
2015-02-17std: Stabilize the IntoIterator traitAlex Crichton-0/+5
Now that the necessary associated types exist for the `IntoIterator` trait this commit stabilizes the trait as-is as well as all existing implementations.
2015-02-17Rollup merge of #22027 - iblech:patch-1, r=steveklabnikManish Goregaokar-2/+2
The first commit adds a short note which I believe will reduce worries in people who work with closures very often and read the Rust book for their first time. The second commit consists solely of tiny typo fixes. In some cases, I changed "logical" quotations like She said, "I like programming". to She said, "I like programming." because the latter seems to be the prevalent style in the book.
2015-02-17Rollup merge of #22313 - japaric:iter, r=aturonManish Goregaokar-0/+25
`IntoIterator` now has an extra associated item: ``` rust trait IntoIterator { type Item; type IntoIter: Iterator<Self=Self::Item>; } ``` This lets you bind the iterator \"`Item`\" directly when writing generic functions: ``` rust // hypothetical change, not included in this PR impl Extend<T> for Vec<T> { // you can now write fn extend<I>(&mut self, it: I) where I: IntoIterator<Item=T> { .. } // instead of fn extend<I: IntoIterator>(&mut self, it: I) where I::IntoIter: Iterator<Item=T> { .. } } ``` The downside is that now you have to write an extra associated type in your `IntoIterator` implementations: ``` diff impl<T> IntoIterator for Vec<T> { + type Item = T; type IntoIter = IntoIter<T>; fn into_iter(self) -> IntoIter<T> { .. } } ``` Because this breaks all downstream implementations of `IntoIterator`, this is a [breaking-change] --- r? @aturon
2015-02-17Rollup merge of #22344 - nagisa:exactsizediter, r=alexcrichtonManish Goregaokar-0/+1
Appears to be just an oversight given it is the only method in a stable trait. r? @aturon because you did final alpha stabilisation of iterators.
2015-02-15Stabilise ExactSizeIterator::lenSimonas Kazlauskas-0/+1