summary refs log tree commit diff
path: root/src/libcore/iter
AgeCommit message (Collapse)AuthorLines
2016-09-20Fix build errorBrian Anderson-1/+0
2016-09-19Remove data structure specialization for .zip() iteratorUlrik Sverdrup-38/+14
Go back on half the specialization, the part that changed the Zip struct's fields themselves depending on the types of the iterators. This means that the Zip iterator will always carry two usize fields, which are unused. If a whole for loop using a .zip() iterator is inlined, these are simply removed and have no effect. The same improvement for Zip of for example slice iterators remain, and they still optimize well. However, like when the specialization of zip was merged, the compiler is still very sensistive to the exact context. For example this code only autovectorizes if the function is used, not if the code in zip_sum_i32 is inserted inline it was called: ``` fn zip_sum_i32(xs: &[i32], ys: &[i32]) -> i32 { let mut s = 0; for (&x, &y) in xs.iter().zip(ys) { s += x * y; } s } fn zipdot_i32_default_zip(b: &mut test::Bencher) { let xs = vec![1; 1024]; let ys = vec![1; 1024]; b.iter(|| { zip_sum_i32(&xs, &ys) }) } ``` Include a test that checks that Zip<T, U> is covariant w.r.t. T and U.
2016-08-22std: 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-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)