]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #8884 : blake2-ppc/rust/exact-size-hint, r=huonw
authorbors <bors@rust-lang.org>
Tue, 3 Sep 2013 13:56:05 +0000 (06:56 -0700)
committerbors <bors@rust-lang.org>
Tue, 3 Sep 2013 13:56:05 +0000 (06:56 -0700)
The message of the first commit explains (edited for changed trait name):

The trait `ExactSize` is introduced to solve a few small niggles:

* We can't reverse (`.invert()`) an enumeration iterator
* for a vector, we have `v.iter().position(f)` but `v.rposition(f)`.
* We can't reverse `Zip` even if both iterators are from vectors

`ExactSize` is an empty trait that is intended to indicate that an
iterator, for example `VecIterator`, knows its exact finite size and
reports it correctly using `.size_hint()`. Only adaptors that preserve
this at all times, can expose this trait further. (Where here we say
finite for fitting in uint).

---

It may seem complicated just to solve these small "niggles",
(It's really the reversible enumerate case that's the most interesting)
but only a few core iterators need to implement this trait.

While we gain more capabilities generically for some iterators,
it becomes a tad more complicated to figure out if a type has
the right trait impls for it.

1  2 
src/libextra/dlist.rs
src/libstd/iterator.rs
src/libstd/str.rs
src/libstd/vec.rs

Simple merge
Simple merge
Simple merge
Simple merge