about summary refs log tree commit diff
path: root/src/libcollections
AgeCommit message (Collapse)AuthorLines
2016-10-27vec: Remove the Vec specialization for .extend()Ulrik Sverdrup-13/+0
This now produces as good code (with optimizations) using the TrustedLen codepath.
2016-10-27impl TrustedLen for vec::IntoIterUlrik Sverdrup-0/+3
2016-10-26Auto merge of #37419 - GuillaumeGomez:rollup, r=GuillaumeGomezbors-22/+22
Rollup of 7 pull requests - Successful merges: #36206, #37144, #37391, #37394, #37396, #37398, #37414 - Failed merges:
2016-10-26Auto merge of #37315 - bluss:fold-more, r=alexcrichtonbors-20/+54
Implement Iterator::fold for .chain(), .cloned(), .map() and the VecDeque iterators. Chain can do something interesting here where it passes on the fold into its inner iterators. The lets the underlying iterator's custom fold() be used, and skips the regular chain logic in next. Also implement .fold() specifically for .map() and .cloned() so that any inner fold improvements are available through map and cloned. The same way, a VecDeque iterator fold can be turned into two slice folds. These changes lend the power of the slice iterator's loop codegen to VecDeque, and to chains of slice iterators, and so on. It's an improvement for .sum() and .product(), and other uses of fold.
2016-10-26Vec docs: fix broken links and make quoting consistentDuncan-22/+22
2016-10-25Special case .fold() for VecDeque's iteratorsUlrik Sverdrup-20/+54
2016-10-22Auto merge of #37327 - aidanhs:aphs-bytes-iter-doc, r=alexcrichtonbors-2/+2
`as_bytes` is not the iterator on String, `bytes` is r? @steveklabnik
2016-10-22Auto merge of #37326 - SimonSapin:from-cow, r=alexcrichtonbors-0/+14
Implement `From<Cow<str>> for String` and `From<Cow<[T]>> for Vec<T>`. Motivation: the `selectors` crate is generic over a string type, in order to support all of `String`, `string_cache::Atom`, and `gecko_string_cache::Atom`. Multiple trait bounds are used for the various operations done with these strings. One of these operations is creating a string (as efficiently as possible, re-using an existing memory allocation if possible) from `Cow<str>`. The `std::convert::From` trait seems natural for this, but the relevant implementation was missing before this PR. To work around this I’ve added a `FromCowStr` trait in `selectors`, but with trait coherence that means one of `selectors` or `string_cache` needs to depend on the other to implement this trait. Using a trait from `std` would solve this. The `Vec<T>` implementation is just added for consistency. I also tried a more general `impl<'a, O, B: ?Sized + ToOwned<Owned=O>> From<Cow<'a, B>> for O`, but (the compiler thinks?) it conflicts with `From<T> for T` the impl (after moving all of `collections::borrow` into `core::borrow` to work around trait coherence).
2016-10-22Rollup merge of #37043 - GuillaumeGomez:vec_urls, r=frewsxcvGuillaume Gomez-52/+85
Add missing urls on Vec docs r? @steveklabnik
2016-10-21`as_bytes` is not the iterator, `bytes` isAidan Hobson Sayers-2/+2
2016-10-21vec: Add a debug assertion where TrustedLen is usedUlrik Sverdrup-1/+7
2016-10-21Implement `From<Cow<str>> for String` and `From<Cow<[T]>> for Vec<T>`.Simon Sapin-0/+14
Motivation: the `selectors` crate is generic over a string type, in order to support all of `String`, `string_cache::Atom`, and `gecko_string_cache::Atom`. Multiple trait bounds are used for the various operations done with these strings. One of these operations is creating a string (as efficiently as possible, re-using an existing memory allocation if possible) from `Cow<str>`. The `std::convert::From` trait seems natural for this, but the relevant implementation was missing before this PR. To work around this I’ve added a `FromCowStr` trait in `selectors`, but with trait coherence that means one of `selectors` or `string_cache` needs to depend on the other to implement this trait. Using a trait from `std` would solve this. The `Vec<T>` implementation is just added for consistency. I also tried a more general `impl<'a, O, B: ?Sized + ToOwned<Owned=O>> From<Cow<'a, B>> for O`, but (the compiler thinks?) it conflicts with `From<T> for T` the impl (after moving all of `collections::borrow` into `core::borrow` to work around trait coherence).
2016-10-21vec: Use Vec::extend specializations in extend_from_slice and moreUlrik Sverdrup-38/+2
The new Vec::extend covers the duties of .extend_from_slice() and some previous specializations.
2016-10-20Use TrustedLen for Vec's FromIterator and ExtendUlrik Sverdrup-10/+37
2016-10-20Add missing urls on Vec docsGuillaume Gomez-52/+85
2016-10-19Rollup merge of #37187 - frewsxcv:cow-doc-example, r=kmcallisterGuillaume Gomez-2/+15
Improve doc example for `std::borrow::Cow`. None
2016-10-16Update comment in Vec::dedup_byFlorian Diebold-1/+1
2016-10-15Auto merge of #37094 - fhartwig:spec-extend-from-slice, r=alexcrichtonbors-1/+18
Specialize Vec::extend to Vec::extend_from_slice I tried using the existing `SpecExtend` as a helper trait for this, but the instances would always conflict with the instances higher up in the file, so I created a new helper trait. Benchmarking `extend` vs `extend_from_slice` with an slice of 1000 `u64`s gives the following results: ``` before: running 2 tests test tests::bench_extend_from_slice ... bench: 166 ns/iter (+/- 78) test tests::bench_extend_trait ... bench: 1,187 ns/iter (+/- 697) after: running 2 tests test tests::bench_extend_from_slice ... bench: 149 ns/iter (+/- 87) test tests::bench_extend_trait ... bench: 138 ns/iter (+/- 70) ```
2016-10-15Improve doc example for `std::borrow::Cow`.Corey Farwell-2/+15
2016-10-13Auto merge of #36743 - SimonSapin:dedup-by, r=alexcrichtonbors-83/+126
Add Vec::dedup_by and Vec::dedup_by_key
2016-10-11Specialize Vec::extend to Vec::extend_from_sliceFlorian Hartwig-1/+18
2016-10-11Rollup merge of #37081 - p512:master, r=sfacklerGuillaume Gomez-1/+1
Changed 0 into '0' Right now `0` is an undefined production rule. [Documentation following the grammar specification](https://doc.rust-lang.org/nightly/std/fmt/#sign0) strongly suggests `'0'` is meant as it is used as a character literal. r? @steveklabnik
2016-10-11Rollup merge of #37073 - GuillaumeGomez:string_url, r=steveklabnikGuillaume Gomez-3/+4
Add missing urls on String module r? @steveklabnik
2016-10-11Rollup merge of #36699 - bluss:repeat-str, r=alexcrichtonGuillaume Gomez-0/+20
Add method str::repeat(self, usize) -> String It is relatively simple to repeat a string n times: `(0..n).map(|_| s).collect::<String>()`. It becomes slightly more complicated to do it “right” (sizing the allocation up front), which warrants a method that does it for us. This method is useful in writing testcases, or when generating text. `format!()` can be used to repeat single characters, but not repeating strings like this.
2016-10-11Merge two `impl<T> Vec<T>` blocks.Simon Sapin-126/+124
The show up separately in rustdoc. This is a separate commit to keep the previous one’s diff shorter.
2016-10-11Add Vec::dedup_by and Vec::dedup_by_keySimon Sapin-1/+46
2016-10-11Changed 0 into '0'p512-1/+1
0 is not a production rule but a literal
2016-10-11Add method str::repeat(self, usize) -> StringUlrik Sverdrup-0/+20
It is relatively simple to repeat a string n times: `(0..n).map(|_| s).collect::<String>()`. It becomes slightly more complicated to do it “right” (sizing the allocation up front), which warrants a method that does it for us. This method is useful in writing testcases, or when generating text. `format!()` can be used to repeat single characters, but not repeating strings like this.
2016-10-10Add missing urls on String moduleGuillaume Gomez-3/+4
2016-10-09Auto merge of #36982 - GuillaumeGomez:slice_urls, r=frewsxcvbors-7/+19
Add missing urls in slice doc module r? @steveklabnik
2016-10-08Add missing urls in slice doc moduleGuillaume Gomez-7/+19
2016-10-07Fix documentation for `write!` on `std::fmt` pageWesley Wiser-2/+2
Fixes #36906
2016-10-06Rollup merge of #36930 - angelsl:issue-36202, r=frewsxcvJonathan Turner-10/+10
Clarify last element in str.{r,}splitn documentation An attempt at #36202. I'm not sure if my wording is actually clearer, to be honest...
2016-10-06Clarify last element in str.{r,}splitn documentationangelsl-10/+10
2016-10-04Rollup merge of #36902 - ollie27:stab_impls, r=alexcrichtonManish Goregaokar-16/+53
std: Correct stability attributes for some implementations These are displayed by rustdoc so should be correct.
2016-10-03Auto merge of #36815 - alexcrichton:stabilize-1.13, r=aturonbors-0/+4
std: Stabilize and deprecate APIs for 1.13 This commit is intended to be backported to the 1.13 branch, and works with the following APIs: Stabilized * `i32::checked_abs` * `i32::wrapping_abs` * `i32::overflowing_abs` * `RefCell::try_borrow` * `RefCell::try_borrow_mut` Deprecated * `BinaryHeap::push_pop` * `BinaryHeap::replace` * `SipHash13` * `SipHash24` * `SipHasher` - use `DefaultHasher` instead in the `std::collections::hash_map` module Closes #28147 Closes #34767 Closes #35057 Closes #35070
2016-10-03std: Stabilize and deprecate APIs for 1.13Alex Crichton-0/+4
This commit is intended to be backported to the 1.13 branch, and works with the following APIs: Stabilized * `i32::checked_abs` * `i32::wrapping_abs` * `i32::overflowing_abs` * `RefCell::try_borrow` * `RefCell::try_borrow_mut` * `DefaultHasher` * `DefaultHasher::new` * `DefaultHasher::default` Deprecated * `BinaryHeap::push_pop` * `BinaryHeap::replace` * `SipHash13` * `SipHash24` * `SipHasher` - use `DefaultHasher` instead in the `std::collections::hash_map` module Closes #28147 Closes #34767 Closes #35057 Closes #35070
2016-10-01std: Correct stability attributes for some implementationsOliver Middleton-16/+53
These are displayed by rustdoc so should be correct.
2016-09-30Auto merge of #36339 - brson:emscripten-new, r=alexcrichtonbors-0/+1
Working asmjs and wasm targets This patch set results in a working standard library for the asmjs-unknown-emscripten and wasm32-unknown-emscripten targets. It is based on the work of @badboy and @rschulman. It does a few things: - Updates LLVM with the emscripten [fastcomp](https://github.com/rust-lang/llvm/pull/50) patches, which include the pnacl IR legalizer and the asm.js backend. This patch is thought not to have any significant effect on existing targets. - Teaches rustbuild to correctly link C code with emscripten - Updates gcc-rs to work correctly with emscripten - Teaches rustbuild to run crate tests for emscripten with node - Modifies Thread::new to return an error on emscripten, to facilitate debugging a common failure mode - Modifies libtest to run in single-threaded mode for emscripten - Ignores a host of tests that don't work yet, mostly dealing with threads and I/O - Updates libc with wasm32 definitions (presently the same as asmjs) - Adds a wasm32-unknown-emscripten target that feeds the output of LLVM's asmjs backend through emcc to generate wasm Notes and caveats: - This is only known to work with `--enable-rustbuild`. - The wasm32 target can't be tested correctly yet because of issues in compiletest and limitations in node https://github.com/kripken/emscripten/issues/4542, but hello.rs does seem to work when run on node via the binaryen interpreter - This requires an up to date installation of the emscripten sdk from its incoming branch - Unwinding is very broken - When enabling the emscripten targets jemalloc is disabled for all targets, which results in test failures for the host Next steps are to fix the jemalloc issue, start building the two emscripten targets on the auto builders, then start producing nightlies. https://github.com/rust-lang/rust/issues/36317 tracks work on this. Fixes https://github.com/rust-lang/rust/issues/36515 Fixes https://github.com/rust-lang/rust/issues/36515 Fixes https://github.com/rust-lang/rust/issues/36356
2016-09-30Ignore lots and lots of std tests on emscriptenBrian Anderson-0/+1
2016-09-30Rollup merge of #36623 - GuillaumeGomez:doc_typos, r=steveklabnikSteve Klabnik-30/+32
Fix some typos and improve doc comments style r? @steveklabnik
2016-09-29Auto merge of #36430 - llogiq:cow_add, r=alexcrichtonbors-1/+47
impl Add<{str, Cow<str>}> for Cow<str> cc #35837
2016-09-29Auto merge of #36377 - tormol:encode_utf, r=alexcrichtonbors-3/+4
Change encode_utf{8,16}() to write to a buffer and panic if it's too small cc #27784 Should the "A buffer that's too small" examples be removed and replaced by tests?
2016-09-29impl {Add, AddAssign}<{str, Cow<str>}> for Cow<str>Andre Bogus-1/+47
This does not actually add anything that wasn't there, but is merely an optimization for the given cases, which would have incurred additional heap allocation for adding empty strings, and improving the ergonomics of `Cow` with strings.
2016-09-28Rollup merge of #36813 - palango:link-to-fmt, r=steveklabnikJonathan Turner-1/+3
Add link to format! docs
2016-09-28Remove stage0 hacksBrian Anderson-2/+0
2016-09-29Add link to format! docsPaul Lange-1/+3
2016-09-28[breaking-change] std: change `encode_utf{8,16}()` to take a buffer and ↵tormol-3/+4
return a slice They panic if the buffer is too small.
2016-09-24Fix some typos and improve doc comments styleGuillaume Gomez-30/+32
2016-09-24Auto merge of #36685 - brson:rev-string-from, r=sfacklerbors-20/+0
Revert "implement `From<Vec<char>>` and `From<&'a [char]>` for `String`" This reverts commit ac73335f2f5421c914fa3900567696cc6dc73d8d. This is a revert of https://github.com/rust-lang/rust/pull/35054, which resulted in at least 7 known regressions, reported [here](https://internals.rust-lang.org/t/regression-report-stable-2016-08-16-vs-beta-2016-09-21/4119) and [here](https://github.com/rust-lang/rust/issues/36352), which will hit stable next week. I think this breakage was somewhat unanticipated, and we did not realize so many crates were broken until this week, so reverting is the conservative thing to do until we figure out how not to cause so much breakage. I've run crater on the revert and did not find any new breakage from the revert. Fixes https://github.com/rust-lang/rust/issues/36352 cc @pwoolcoc @rust-lang/libs