about summary refs log tree commit diff
path: root/src/libcore/iter
AgeCommit message (Collapse)AuthorLines
2016-09-12remove ExactSizeIterator from RangeInclusive<u/isize>Alex Burka-2/+9
2016-09-10Inherit overflow checks for sum and productSteven Fackler-14/+11
2016-09-09fix silent overflows on `Step` implsMatthew Piziak-0/+6
r? @eddyb
2016-09-02Auto merge of #35856 - phimuemue:master, r=brsonbors-0/+53
Introduce max_by/min_by on iterators See https://github.com/rust-lang/rfcs/issues/1722 for reference. It seems that there is `min`, `max` (simple computation of min/max), `min_by_key`, `max_by_key` (min/max by comparing mapped values) but no `min_by` and `max_by` (min/max according to comparison function). However, e.g. on vectors or slices there is `sort`, `sort_by_key` and `sort_by`.
2016-08-29Changed issue number to 36105philipp-2/+2
2016-08-26accumulate vector and assert for RangeFrom and RangeInclusive examplesMatthew Piziak-22/+10
PR #35695 for `Range` was approved, so it seems that this side-effect-free style is preferred for Range* examples. This PR performs the same translation for `RangeFrom` and `RangeInclusive`. It also removes what looks to be an erroneously commented line for `#![feature(step_by)]`, and an unnecessary primitive-type annotation in `0u8..`. add `fn main` wrappers to enable Rust Playground "Run" button
2016-08-24Use `#[prelude_import]` in `libcore`.Jeffrey Seyfried-27/+4
2016-08-23Auto merge of #35656 - Stebalien:fused, r=alexcrichtonbors-8/+173
Implement 1581 (FusedIterator) * [ ] Implement on patterns. See https://github.com/rust-lang/rust/issues/27721#issuecomment-239638642. * [ ] Handle OS Iterators. A bunch of iterators (`Args`, `Env`, etc.) in libstd wrap platform specific iterators. The current ones all appear to be well-behaved but can we assume that future ones will be? * [ ] Does someone want to audit this? On first glance, all of the iterators on which I implemented `FusedIterator` appear to be well-behaved but there are a *lot* of them so a second pair of eyes would be nice. * I haven't touched rustc internal iterators (or the internal rand) because rustc doesn't actually call `fuse()`. * `FusedIterator` can't be implemented on `std::io::{Bytes, Chars}`. Closes: #35602 (Tracking Issue) Implements: rust-lang/rfcs#1581
2016-08-21Added #![feature] declarationsphilipp-0/+2
2016-08-20Introduce max_by/min_by on iteratorsphilipp-0/+51
2016-08-19std: Stabilize APIs for the 1.12 releaseAlex Crichton-10/+12
Stabilized * `Cell::as_ptr` * `RefCell::as_ptr` * `IpAddr::is_{unspecified,loopback,multicast}` * `Ipv6Addr::octets` * `LinkedList::contains` * `VecDeque::contains` * `ExitStatusExt::from_raw` - both on Unix and Windows * `Receiver::recv_timeout` * `RecvTimeoutError` * `BinaryHeap::peek_mut` * `PeekMut` * `iter::Product` * `iter::Sum` * `OccupiedEntry::remove_entry` * `VacantEntry::into_key` Deprecated * `Cell::as_unsafe_cell` * `RefCell::as_unsafe_cell` * `OccupiedEntry::remove_pair` Closes #27708 cc #27709 Closes #32313 Closes #32630 Closes #32713 Closes #34029 Closes #34392 Closes #34285 Closes #34529
2016-08-18Add a FusedIterator trait.Steven Allen-8/+173
This trait can be used to avoid the overhead of a fuse wrapper when an iterator is already well-behaved. Conforming to: RFC 1581 Closes: #35602
2016-08-15remove `.take(10)` from `Range` exampleMatthew Piziak-1/+1
2016-08-15accumulate into vector and assert, instead of printingMatthew Piziak-15/+2
I'm only making this change in one place so that people can express their preferences for this stylistic change. If/when this change is approved I'll go ahead and translate the rest of the `std::ops` examples.
2016-08-06Indicate tracking issue for `exact_size_is_empty` unstability.Corey Farwell-1/+1
2016-07-26Rollup merge of #34732 - durka:patch-27, r=steveklabnikSteve Klabnik-3/+4
document DoubleEndedIterator::next_back document DoubleEndedIterator::next_back fixes #34726
2016-07-18Auto merge of #34357 - tbu-:pr_exact_size_is_empty, r=brsonbors-2/+28
Add `is_empty` function to `ExactSizeIterator` All other types implementing a `len` functions have `is_empty` already.
2016-07-18Fix doctest of `ExactSizeIterator::is_empty`Tobias Bucher-1/+3
2016-07-12std: Clean out deprecated APIsAlex Crichton-33/+0
This primarily removes a lot of `sync::Static*` APIs and rejiggers the associated implementations. While doing this it was discovered that the `is_poisoned` method can actually result in a data race for the Mutex/RwLock primitives, so the inner `Cell<bool>` was changed to an `AtomicBool` to prevent the associated data race. Otherwise the usage/gurantees should be the same they were before.
2016-07-08document DoubleEndedIterator::next_backAlex Burka-3/+4
fixes #34726
2016-07-08Rollup merge of #34688 - GuillaumeGomez:double_ended_iterator, r=steveklabnikManish Goregaokar-6/+12
Improve DoubleEndedIterator examples Fixes #34065. r? @steveklabnik
2016-07-06Rollup merge of #33265 - tshepang:peek, r=steveklabnikSteve Klabnik-11/+9
doc: some `peek` improvements
2016-07-06Improve DoubleEndedIterator examplesGuillaume Gomez-6/+12
2016-07-03std: Stabilize APIs for the 1.11.0 releaseAlex Crichton-58/+267
Although the set of APIs being stabilized this release is relatively small, the trains keep going! Listed below are the APIs in the standard library which have either transitioned from unstable to stable or those from unstable to deprecated. Stable * `BTreeMap::{append, split_off}` * `BTreeSet::{append, split_off}` * `Cell::get_mut` * `RefCell::get_mut` * `BinaryHeap::append` * `{f32, f64}::{to_degrees, to_radians}` - libcore stabilizations mirroring past libstd stabilizations * `Iterator::sum` * `Iterator::product` Deprecated * `{f32, f64}::next_after` * `{f32, f64}::integer_decode` * `{f32, f64}::ldexp` * `{f32, f64}::frexp` * `num::One` * `num::Zero` Added APIs (all unstable) * `iter::Sum` * `iter::Product` * `iter::Step` - a few methods were added to accomodate deprecation of One/Zero Removed APIs * `From<Range<T>> for RangeInclusive<T>` - everything about `RangeInclusive` is unstable Closes #27739 Closes #27752 Closes #32526 Closes #33444 Closes #34152 cc #34529 (new tracking issue)
2016-06-21Auto merge of #34155 - ollie27:unzip, r=alexcrichtonbors-15/+0
Remove unzip() SizeHint hack This was using an invalid iterator so is likely to end with buggy behaviour. It also doesn't even benefit many type in std including Vec so removing it shouldn't cause any problems. Fixes: #33468
2016-06-19Remove first empty line of doc commentTobias Bucher-1/+0
2016-06-19Add `is_empty` function to `ExactSizeIterator`Tobias Bucher-2/+27
All other types implementing a `len` functions have `is_empty` already.
2016-06-14specialize zip: Use associated type for specialized zip struct dataUlrik Sverdrup-13/+39
The associated type must be 'static to avoid dropck related errors.
2016-06-14specialize zip: TrustedRandomAccess for EnumerateUlrik Sverdrup-0/+9
2016-06-14specialize zip: TrustedRandomAccess for ZipUlrik Sverdrup-0/+11
2016-06-14specialize zip: Specialize .zip() for TrustedRandomAccess iteratorsUlrik Sverdrup-21/+121
This allows common iterator compositions like a.zip(b) where a, b are slice::{Iter, IterMut} compile to *much* better code.
2016-06-07Remove unzip() SizeHint hackOliver Middleton-15/+0
This was using an invalid iterator so is likely to end with buggy behaviour. It also doesn't even benefit many type in std including Vec so removing it shouldn't cause any problems.
2016-06-05core: mark relevant functions with #[rustc_inherit_overflow_checks].Eduard Burtescu-0/+5
2016-05-24std: Stabilize APIs for the 1.10 releaseAlex Crichton-0/+1
This commit applies the FCP decisions made by the libs team for the 1.10 cycle, including both new stabilizations and deprecations. Specifically, the list of APIs is: Stabilized: * `os::windows::fs::OpenOptionsExt::access_mode` * `os::windows::fs::OpenOptionsExt::share_mode` * `os::windows::fs::OpenOptionsExt::custom_flags` * `os::windows::fs::OpenOptionsExt::attributes` * `os::windows::fs::OpenOptionsExt::security_qos_flags` * `os::unix::fs::OpenOptionsExt::custom_flags` * `sync::Weak::new` * `Default for sync::Weak` * `panic::set_hook` * `panic::take_hook` * `panic::PanicInfo` * `panic::PanicInfo::payload` * `panic::PanicInfo::location` * `panic::Location` * `panic::Location::file` * `panic::Location::line` * `ffi::CStr::from_bytes_with_nul` * `ffi::CStr::from_bytes_with_nul_unchecked` * `ffi::FromBytesWithNulError` * `fs::Metadata::modified` * `fs::Metadata::accessed` * `fs::Metadata::created` * `sync::atomic::Atomic{Usize,Isize,Bool,Ptr}::compare_exchange` * `sync::atomic::Atomic{Usize,Isize,Bool,Ptr}::compare_exchange_weak` * `collections::{btree,hash}_map::{Occupied,Vacant,}Entry::key` * `os::unix::net::{UnixStream, UnixListener, UnixDatagram, SocketAddr}` * `SocketAddr::is_unnamed` * `SocketAddr::as_pathname` * `UnixStream::connect` * `UnixStream::pair` * `UnixStream::try_clone` * `UnixStream::local_addr` * `UnixStream::peer_addr` * `UnixStream::set_read_timeout` * `UnixStream::set_write_timeout` * `UnixStream::read_timeout` * `UnixStream::write_Timeout` * `UnixStream::set_nonblocking` * `UnixStream::take_error` * `UnixStream::shutdown` * Read/Write/RawFd impls for `UnixStream` * `UnixListener::bind` * `UnixListener::accept` * `UnixListener::try_clone` * `UnixListener::local_addr` * `UnixListener::set_nonblocking` * `UnixListener::take_error` * `UnixListener::incoming` * RawFd impls for `UnixListener` * `UnixDatagram::bind` * `UnixDatagram::unbound` * `UnixDatagram::pair` * `UnixDatagram::connect` * `UnixDatagram::try_clone` * `UnixDatagram::local_addr` * `UnixDatagram::peer_addr` * `UnixDatagram::recv_from` * `UnixDatagram::recv` * `UnixDatagram::send_to` * `UnixDatagram::send` * `UnixDatagram::set_read_timeout` * `UnixDatagram::set_write_timeout` * `UnixDatagram::read_timeout` * `UnixDatagram::write_timeout` * `UnixDatagram::set_nonblocking` * `UnixDatagram::take_error` * `UnixDatagram::shutdown` * RawFd impls for `UnixDatagram` * `{BTree,Hash}Map::values_mut` * `<[_]>::binary_search_by_key` Deprecated: * `StaticCondvar` - this, and all other static synchronization primitives below, are usable today through the lazy-static crate on stable Rust today. Additionally, we'd like the non-static versions to be directly usable in a static context one day, so they're unlikely to be the final forms of the APIs in any case. * `CONDVAR_INIT` * `StaticMutex` * `MUTEX_INIT` * `StaticRwLock` * `RWLOCK_INIT` * `iter::Peekable::is_empty` Closes #27717 Closes #27720 cc #27784 (but encode methods still exist) Closes #30014 Closes #30425 Closes #30449 Closes #31190 Closes #31399 Closes #31767 Closes #32111 Closes #32281 Closes #32312 Closes #32551 Closes #33018
2016-05-11doc: some `peek` improvementsTshepang Lekhonkhobe-11/+9
2016-05-04Update iterator.rsKaiyin Zhong-1/+1
2016-05-04errors in the docKaiyin Zhong-2/+2
2016-04-30Implement find() on Chain iteratorsGeorg Brandl-0/+17
This results in a roughly 2x speedup compared to the default impl "inherited" from Iterator.
2016-04-22Make the `Iterator::enumerate` doc example more clearNick Fitzgerald-5/+4
The example uses integers for the value being iterated over, but the indices added by `enumerate` are also integers, so I always end up double taking and thinking harder than I should when parsing the documentation. I also always forget which order the index and value are in the tuple so I frequently hit this stumbling block. This commit changes the documentation to iterate over characters so that it is immediately obvious which part of the tuple is the index and which is the value.
2016-04-18core::iter: Move ExactSizeIterator impls to each struct definitionUlrik Sverdrup-19/+19
2016-04-18core::iter: break long linesUlrik Sverdrup-2/+5
2016-04-18Split core::iter module implementation into partsUlrik Sverdrup-0/+5110
split iter.rs into a directory of (implementation private) modules. + mod Adaptor structs - Private fields need to be available both for them and Iterator + iterator (Iterator trait) + traits (FromIterator, traits but Iterator itself) + range (range related) + sources (Repeat, Once, Empty)