about summary refs log tree commit diff
path: root/src/libcollections
AgeCommit message (Collapse)AuthorLines
2016-09-23Revert "implement `From<Vec<char>>` and `From<&'a [char]>` for `String`"Brian Anderson-20/+0
This reverts commit ac73335f2f5421c914fa3900567696cc6dc73d8d.
2016-09-23Minor `VecDeque` doc examples cleanup.Corey Farwell-5/+5
2016-09-20Minor correction in `sort_by_key` doc commentNick Platt-1/+1
2016-09-14Auto merge of #36347 - knight42:str-replacen, r=alexcrichtonbors-0/+43
Implement std::str::replacen Replaces first N matches of a pattern with another string. ``` assert_eq!("acaaa".replacen(a, "b", 3), "bcbba") ```
2016-09-14Rollup merge of #36396 - athulappadan:Default-docs, r=blussGuillaume Gomez-0/+8
Documentation of what Default does for each type Addresses #36265 I haven't changed the following types due to doubts: 1)src/libstd/ffi/c_str.rs 2)src/libcore/iter/sources.rs 3)src/libcore/hash/mod.rs 4)src/libcore/hash/mod.rs 5)src/librustc/middle/privacy.rs r? @steveklabnik
2016-09-13Doc correction: btreeathulappadan-1/+1
2016-09-13Implement std::str::replacenknight42-0/+43
2016-09-11Documentation for default types modifiedathulappadan-3/+3
2016-09-11Documentation of what does for each typeathulappadan-0/+8
2016-09-09Work around pointer aliasing issue in Vec::extend_from_slice, ↵Ulrik Sverdrup-13/+55
extend_with_element Due to missing noalias annotations for &mut T in general (issue #31681), in larger programs extend_from_slice and extend_with_element may both compile very poorly. What is observed is that the .set_len() calls are not lifted out of the loop, even for `Vec<u8>`. Use a local length variable for the Vec length instead, and use a scope guard to write this value back to self.len when the scope ends or on panic. Then the alias analysis is easy. This affects extend_from_slice, extend_with_element, the vec![x; n] macro, Write impls for Vec<u8>, BufWriter, etc (but may / may not have triggered since inlining can be enough for the compiler to get it right).
2016-09-06Rollup merge of #36243 - GuillaumeGomez:hash_map_links, r=steveklabnikJonathan Turner-4/+8
Add missing urls r? @steveklabnik
2016-09-03Add missing urlsGuillaume Gomez-4/+8
2016-09-03Auto merge of #36072 - arthurprs:binary_heap_opt, r=Aatchbors-20/+23
Optimize BinaryHeap bounds checking I was experimenting with d-ary binary heaps during the weekend (dead end) and I found that we could get some good improvements by removing bounds checking. Specially due to the panic-safe additional code, llvm can't really optimize them out. ``` name d_ary_heap:: ns/iter std___heap:: ns/iter diff ns/iter diff % bench_build_insert 148,610 236,960 88,350 59.45% bench_from_vec 243,846 299,719 55,873 22.91% bench_insert_2000_empty 4,512 7,517 3,005 66.60% bench_insert_2000_prefilled 28,665 32,605 3,940 13.74% bench_pop_2000 111,515 128,005 16,490 14.79% bench_pop_all 2,759,945 3,317,626 557,681 20.21% peek_mut 23,186 23,635 449 1.94% pop_modify_push 41,573 43,822 2,249 5.41% test d_ary_heap::bench_build_insert ... bench: 148,610 ns/iter (+/- 10,687) test d_ary_heap::bench_from_vec ... bench: 243,846 ns/iter (+/- 16,500) test d_ary_heap::bench_insert_2000_empty ... bench: 4,512 ns/iter (+/- 136) test d_ary_heap::bench_insert_2000_prefilled ... bench: 28,665 ns/iter (+/- 1,347) test d_ary_heap::bench_pop_2000 ... bench: 111,515 ns/iter (+/- 104,677) test d_ary_heap::bench_pop_all ... bench: 2,759,945 ns/iter (+/- 173,838) test d_ary_heap::peek_mut ... bench: 23,186 ns/iter (+/- 106,254) test d_ary_heap::pop_modify_push ... bench: 41,573 ns/iter (+/- 3,313) test std___heap::bench_build_insert ... bench: 236,960 ns/iter (+/- 16,955) test std___heap::bench_from_vec ... bench: 299,719 ns/iter (+/- 6,354) test std___heap::bench_insert_2000_empty ... bench: 7,517 ns/iter (+/- 372) test std___heap::bench_insert_2000_prefilled ... bench: 32,605 ns/iter (+/- 2,433) test std___heap::bench_pop_2000 ... bench: 128,005 ns/iter (+/- 11,787) test std___heap::bench_pop_all ... bench: 3,317,626 ns/iter (+/- 238,968) test std___heap::peek_mut ... bench: 23,635 ns/iter (+/- 1,420) test std___heap::pop_modify_push ... bench: 43,822 ns/iter (+/- 3,788) ``` Test code: https://github.com/arthurprs/heap-experiments
2016-08-30Rollup merge of #35862 - Stebalien:fmt-docs, r=steveklabnikGuillaume Gomez-3/+9
Clarify/fix formatting docs concerning fmt::Result/fmt::Error 1. `fmt::Result` != `io::Result<()>` 2. Formatters should only propagate errors, not return their own. Confusion on reddit: https://www.reddit.com/r/rust/comments/4yorxr/is_implt_tostring_for_t_where_t_display_sized_a/
2016-08-29Remove BinaryHeap bounds checkingarthurprs-20/+23
2016-08-25Auto merge of #35906 - jseyfried:local_prelude, r=eddybbors-15/+2
Use `#[prelude_import]` in `libcore` and `libstd` r? @eddyb
2016-08-24Remove needless imports in `libcollections`.Jeffrey Seyfried-15/+2
2016-08-24Remove drop flags from structs and enums implementing Drop.Eduard Burtescu-7/+5
2016-08-23Rust has type aliases, not typedefs.Steven Allen-9/+9
They're the same thing but it's better to keep the terminology consistent.
2016-08-23Auto merge of #35656 - Stebalien:fused, r=alexcrichtonbors-8/+100
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-21Fix "Furthermore" Typo in String DocsChristopher Serr-1/+1
It used to say "Furtheremore" instead of "Furthermore".
2016-08-20Note that formatters should not return spurious errors.Steven Allen-2/+8
Doing otherwise would break traits like `ToString`.
2016-08-20Correct formatting docs: fmt::Result != io::Result<()>Steven Allen-3/+3
2016-08-20Rollup merge of #35234 - nrc:rustdoc-macros, r=steveklabnikJonathan Turner-1/+1
rustdoc: remove the `!` from macro URLs and titles Because the `!` is part of a macro use, not the macro's name. E.g., you write `macro_rules! foo` not `macro_rules! foo!`, also `#[macro_import(foo)]`. (Pulled out of #35020).
2016-08-19std: Stabilize APIs for the 1.12 releaseAlex Crichton-22/+18
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/+100
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-18Fix linksNick Cameron-1/+1
2016-08-17Auto merge of #35747 - jonathandturner:rollup, r=jonathandturnerbors-0/+9
Rollup of 23 pull requests - Successful merges: #34370, #35415, #35595, #35610, #35613, #35614, #35621, #35660, #35663, #35670, #35671, #35672, #35681, #35686, #35690, #35695, #35707, #35708, #35713, #35722, #35725, #35726, #35731 - Failed merges: #35395
2016-08-17Auto merge of #35733 - apasel422:issue-35721, r=alexcrichtonbors-6/+9
Make `vec::IntoIter` covariant again Closes #35721 r? @alexcrichton
2016-08-17Rollup merge of #35707 - frewsxcv:vec-into-iter-debug, r=alexcrichtonJonathan Turner-0/+9
Implement `Debug` for `std::vec::IntoIter`. Display all the remaining items of the iterator, similar to the `Debug` implementation for `core::slice::Iter`: https://github.com/rust-lang/rust/blob/f0bab98695f0a4877daabad9a5b0ba3e66121392/src/libcore/slice.rs#L930-L937 Using the `as_slice` method that was added in: https://github.com/rust-lang/rust/pull/35447
2016-08-16Make `vec::IntoIter` covariant againAndrew Paseltiner-6/+9
Closes #35721
2016-08-16Auto merge of #35354 - tomgarcia:covariant-drain, r=alexcrichtonbors-3/+4
Made vec_deque::Drain, hash_map::Drain, and hash_set::Drain covariant Fixed the rest of the Drain iterators.
2016-08-15Implement `Debug` for `std::vec::IntoIter`.Corey Farwell-0/+9
Display all the remaining items of the iterator, similar to the `Debug` implementation for `core::slice::Iter`: https://github.com/rust-lang/rust/blob/f0bab98695f0a4877daabad9a5b0ba3e66121392/src/libcore/slice.rs#L930-L937 Using the `as_slice` method that was added in: https://github.com/rust-lang/rust/pull/35447
2016-08-14Rollup merge of #35598 - tshepang:needless-binding, r=steveklabnikEduard-Mihai Burtescu-2/+1
string: remove needless binding
2016-08-14Rollup merge of #35597 - tshepang:it-is-a-slice, r=steveklabnikEduard-Mihai Burtescu-1/+1
doc: a value of type `&str` is called a "string slice"
2016-08-14Rollup merge of #35447 - frewsxcv:vec-into-iter-as-slice, r=alexcrichtonEduard-Mihai Burtescu-12/+51
Introduce `as_slice`/`as_mut_slice` methods on `std::vec::IntoIter` struct. Similar to the `as_slice` method on `core::slice::Iter` struct.
2016-08-11Introduce `as_mut_slice` method on `std::vec::IntoIter` struct.Corey Farwell-9/+29
2016-08-11Introduce `as_slice` method on `std::vec::IntoIter` struct.Corey Farwell-3/+22
Similar to the `as_slice` method on `core::slice::Iter` struct.
2016-08-11string: remove needless bindingTshepang Lekhonkhobe-2/+1
2016-08-11doc: a value of type `&str` is called a "string slice"Tshepang Lekhonkhobe-1/+1
2016-08-09Add tracking issue for `String::insert_str`Murarth-1/+1
2016-08-08Auto merge of #34762 - creativcoder:slice-ext, r=alexcrichtonbors-4/+4
extend lifetime on binary_search_by_key of SliceExt trait Fixes #34683.
2016-08-09extend lifetime on binary_search_by_key of SliceExt traitRahul Sharma-4/+4
2016-08-07Add `FromIterator` implementations for `Cow<str>`Alexander Altman-0/+21
This seems like an oversight, since the corresponding implementation for `Cow<[T]> where T: Clone` exists.
2016-08-05Rollup merge of #35181 - GuillaumeGomez:vec_doc, r=steveklabnikGuillaume Gomez-0/+19
Add doc example for Vec Fixes #29380. r? @steveklabnik
2016-08-04Made vec_deque::Drain, hash_map::Drain, and hash_set::Drain covariantThomas Garcia-3/+4
2016-08-02Add doc example for VecGuillaume Gomez-0/+19
2016-08-02Add doc examples for `range::RangeArgument::{start,end}`.Corey Farwell-0/+32
2016-08-01Auto merge of #35054 - pwoolcoc:stringfromchars, r=brsonbors-0/+20
implement `From<Vec<char>>` and `From<&'a [char]>` for `String` Though there are ways to convert a slice or vec of chars into a string, it would be nice to be able to just do `String::from(&['a', 'b', 'c'])`, so this PR implements `From<Vec<char>>` and `From<&'a [char]>` for String.
2016-08-02Rollup merge of #35134 - frewsxcv:slice-chunks, r=GuillaumeGomezSeo Sanghyeon-9/+7
Rewrite `slice::chunks` doc example to not require printing. None