summary refs log tree commit diff
path: root/src/libcollections
AgeCommit message (Collapse)AuthorLines
2015-06-17Implement Borrow<T> and BorrowMut<T> for Box<T: ?Sized>Ulrik Sverdrup-1/+9
Conflicts: src/libcollections/borrow.rs
2015-06-09properly null out ptr in LinkedList::split_off - fixes #26020Alexis Beingessner-0/+26
2015-06-09collections: Make BinaryHeap panic safe in sift_up / sift_downUlrik Sverdrup-25/+88
Use a struct called Hole that keeps track of an invalid location in the vector and fills the hole on drop. I include a run-pass test that the current BinaryHeap fails, and the new one passes. Fixes #25842
2015-05-14Add #[inline] to Borrow<str>::borrow for String.Jan Bujak-0/+1
2015-05-13Small cleanup to vec docsSteve Klabnik-10/+12
Add the repeating form of the vec macro Remove unneeded literal annotations. Use more conventional variable names.
2015-05-12TRPL: Borrow and AsRefSteve Klabnik-0/+5
These two traits are commonly confused. As such, explain the difference. Fixes #24163
2015-05-11Rollup merge of #25288 - DrKwint:master, r=alexcrichtonSteve Klabnik-3/+3
The functions BitSet::{iter,union,symmetric_difference} each had docs that claimed u32s were output when their actual output each end up being usizes. r? @steveklabnik
2015-05-11Auto merge of #25301 - jooert:vec_map_fix_split_off, r=Gankrobors-1/+1
We don't need to copy any elements if `at` is behind the last element in the map. The last element is at index `self.v.len() - 1`, so we should not copy if `at` is greater **or equals** `self.v.len()`. r? @Gankro
2015-05-11Rollup merge of #25290 - bluss:docfixes, r=steveklabnikManish Goregaokar-2/+3
Several Minor API / Reference Documentation Fixes - Fix a few small errors in the reference. - Fix paper cuts in the API docs. Fixes #24882 Fixes #25233 Fixes #25250
2015-05-11Minor optimization for `VecMap::split_off`Johannes Oertel-1/+1
We don't need to copy any elements if `at` is behind the last element in the map. The last element is at index `self.v.len() - 1`, so we should not copy if `at` is greater or equals `self.v.len()`.
2015-05-11docs: Update SliceConcatExt docs for assoc typesUlrik Sverdrup-2/+3
2015-05-11Auto merge of #24934 - jooert:bitset-append-split_off, r=Gankrobors-0/+83
cc #19986
2015-05-10Update BitSet docs to correct typesPaul Quint-3/+3
Update BitSet docs to correct type in one more spot removed accidental file
2015-05-10Rollup merge of #25158 - koute:master, r=alexcrichtonSteve Klabnik-0/+1
I was profiling my code again and this time AsRef<str> for String was eating up a considerable chunk of my runtime; adding the inline annotation made the program run almost twice as fast! While I was at it I also added the annotation to other implementations of AsRef as well as AsMut.
2015-05-10Implement `append` and `split_off` for BitSet (RFC 509)Johannes Oertel-0/+83
2015-05-10Add #[inline] to AsRef<str>::as_ref for String and str.Jan Bujak-0/+1
2015-05-09Rollup merge of #25227 - jooert:bitvec-doc-fix, r=alexcrichtonManish Goregaokar-0/+4
I forgot this in #24890.
2015-05-09Auto merge of #25162 - seanmonstar:asref-bytes, r=alexcrichtonbors-12/+18
r? @aturon
2015-05-08collections: change bounds of SliceConcatExt implementations to use Borrow ↵Sean McArthur-12/+10
instead of AsRef
2015-05-08collections: impl AsRef<[u8]> for StringSean McArthur-0/+8
2015-05-09Document panic behaviour of BitVec::split_offJohannes Oertel-0/+4
2015-05-08Auto merge of #25187 - alexcrichton:mem-forget-safe, r=brsonbors-2/+2
This commit is an implementation of [RFC 1066][rfc] where the conclusion was that leaking a value is a safe operation in Rust code, so updating the signature of this function follows suit. [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1066-safe-mem-forget.md Closes #25186
2015-05-07std: Mark `mem::forget` as a safe functionAlex Crichton-2/+2
This commit is an implementation of [RFC 1066][rfc] where the conclusion was that leaking a value is a safe operation in Rust code, so updating the signature of this function follows suit. [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1066-safe-mem-forget.md Closes #25186
2015-05-07Auto merge of #25157 - alexcrichton:remove-vec-add, r=aturonbors-12/+1
Ideally this trait implementation would be unstable, requiring crates to opt-in if they would like the functionality, but that's not currently how stability works so the implementation needs to be removed entirely. This may come back at a future date, but for now the conservative option is to remove it. [breaking-change]
2015-05-07Auto merge of #24890 - jooert:bitvec-append-split_off, r=alexcrichtonbors-0/+101
cc #19986 r? @Gankro
2015-05-06std: Remove addition on vectors for nowAlex Crichton-12/+1
Ideally this trait implementation would be unstable, requiring crates to opt-in if they would like the functionality, but that's not currently how stability works so the implementation needs to be removed entirely. This may come back at a future date, but for now the conservative option is to remove it. [breaking-change]
2015-05-06Auto merge of #25120 - bluss:sliceconcatext, r=alexcrichtonbors-6/+14
collections: Convert SliceConcatExt to use associated types Coherence now allows this, we have `SliceConcatExt<T> for [V] where T: Sized + Clone` and` SliceConcatExt<str> for [S]`, these don't conflict because str is never Sized.
2015-05-06Implement append and split_off for BitVec (RFC 509)Johannes Oertel-0/+101
2015-05-06Auto merge of #24879 - Stebalien:vec_deque, r=alexcrichtonbors-0/+36
According to rust-lang/rfcs#235, `VecDeque` should have this method (`VecDeque` was called `RingBuf` at the time) but it was never implemented. I marked this stable since "1.0.0" because it's stable in `Vec`.
2015-05-05collections: Convert SliceConcatExt to use associated typesUlrik Sverdrup-6/+14
Coherence now allows this, we have SliceConcatExt<T> for [V] where T: Sized + Clone and SliceConcatExt<str> for [S], these don't conflict because str is never Sized.
2015-05-05Auto merge of #25111 - Manishearth:rollup, r=Manishearthbors-7/+15
r? @Manishearth
2015-05-05Rollup merge of #25100 - jbcrail:fix-spelling-errors, r=steveklabnikManish Goregaokar-3/+3
I corrected several spelling errors in the external documentation.
2015-05-05Rollup merge of #25087 - nham:improve_vec_docs, r=GankroManish Goregaokar-4/+12
This commit does two things: it adds an example for indexing vectors, and it changes the \"Examples\" section to use full sentences. This change was spurred by someone in the #rust IRC channel asking if there was a `.set()` method for changing the `i`-th value of a vector (they had missed that `Vec` implements `IndexMut`, which is easy to do if you're not aware of that trait).
2015-05-04Implement retain for vec_dequeSteven Allen-0/+36
2015-05-05Auto merge of #25095 - huonw:faster-bitvec, r=alexcrichtonbors-6/+4
This makes the `bit::vec::bench::bench_bit_vec_big_union` benchmark go from `774 ns/iter (+/- 190)` to `602 ns/iter (+/- 5)`. (There's room for more work here too: if one can guarantee 128-bit alignment for the vector, the compiler actually optimises `union`, `intersection` etc. to SIMD instructions, which end up being ~5x faster that the original version, and 4x faster than the optimised version in this patch.)
2015-05-04Fix spelling errors in documentation.Joseph Crail-3/+3
2015-05-04Make `BitVec::process` faster (branch free).Huon Wilson-6/+4
This makes the `bit::vec::bench::bench_bit_vec_big_union` benchmark go from `774 ns/iter (+/- 190)` to `602 ns/iter (+/- 5)`. (There's room for more work here too: if one can guarantee 128-bit alignment for the vector, the compiler actually optimises `union`, `intersection` etc. to SIMD instructions, which end up being ~5x faster that the original version, and 4x faster than the optimised version in this patch.)
2015-05-03Improve std::vec module documentation.Nick Hamann-4/+12
This changes the std::vec module docs to use full sentences. It also adds an example for indexing vectors.
2015-05-04Auto merge of #25047 - sinkuu:vec_intoiter_override, r=alexcrichtonbors-0/+5
Override methods `count`, `last`, and `nth` in vec::IntoIter. #24214
2015-05-03Auto merge of #25064 - tshepang:brevity, r=alexcrichtonbors-10/+2
2015-05-03doc: make concat() and connect() examples briefTshepang Lekhonkhobe-10/+2
2015-05-02Override Iterator::count method in vec::IntoItersinkuu-0/+5
2015-05-02Auto merge of #25028 - bluss:drain-string, r=alexcrichtonbors-1/+107
collections: Implement String::drain(range) according to RFC 574 `.drain(range)` is unstable and under feature(collections_drain). This adds a safe way to remove any range of a String as efficiently as possible. As noted in the code, this drain iterator has none of the memory safety issues of the vector version. RFC tracking issue is #23055
2015-05-01Auto merge of #25006 - alexcrichton:unstable-indexing, r=aturonbors-14/+16
These implementations were intended to be unstable, but currently the stability attributes cannot handle a stable trait with an unstable `impl` block. This commit also audits the rest of the standard library for explicitly-`#[unstable]` impl blocks. No others were removed but some annotations were changed to `#[stable]` as they're defacto stable anyway. One particularly interesting `impl` marked `#[stable]` as part of this commit is the `Add<&[T]>` impl for `Vec<T>`, which uses `push_all` and implicitly clones all elements of the vector provided. Closes #24791 [breaking-change]
2015-05-01collections: Implement String::drain(range) according to RFC 574Ulrik Sverdrup-1/+107
`.drain(range)` is unstable and under feature(collections_drain). This adds a safe way to remove any range of a String as efficiently as possible. As noted in the code, this drain iterator has none of the memory safety issues of the vector version. RFC tracking issue is #23055
2015-05-01std: Remove index notation on slice iteratorsAlex Crichton-14/+16
These implementations were intended to be unstable, but currently the stability attributes cannot handle a stable trait with an unstable `impl` block. This commit also audits the rest of the standard library for explicitly-`#[unstable]` impl blocks. No others were removed but some annotations were changed to `#[stable]` as they're defacto stable anyway. One particularly interesting `impl` marked `#[stable]` as part of this commit is the `Add<&[T]>` impl for `Vec<T>`, which uses `push_all` and implicitly clones all elements of the vector provided. Closes #24791
2015-04-30Clarify intention wrt integersSteve Klabnik-1/+1
Fixes #24767
2015-04-28Register new snapshotsTamir Duberstein-13/+0
2015-04-28Auto merge of #24781 - bluss:vec-drain-range, r=alexcrichtonbors-81/+137
Implement Vec::drain(\<range type\>) from rust-lang/rfcs#574, tracking issue #23055. This is a big step forward for vector usability. This is an introduction of an API for removing a range of *m* consecutive elements from a vector, as efficently as possible. New features: - Introduce trait `std::collections::range::RangeArgument` implemented by all four built-in range types. - Change `Vec::drain()` to use `Vec::drain<R: RangeArgument>(R)` Implementation notes: - Use @Gankro's idea for memory safety: Use `set_len` on the source vector when creating the iterator, to make sure that the part of the vector that will be modified is unreachable. Fix up things in Drain's destructor — but even if it doesn't run, we don't expose any moved-out-from slots of the vector. - This `.drain<R>(R)` very close to how it is specified in the RFC. - Introduced as unstable - Drain reuses the slice iterator — copying and pasting the same iterator pointer arithmetic again felt very bad - The `usize` index as a range argument in the RFC is not included. The ranges trait would have to change to accomodate it. Please help me with: - Name and location of the new ranges trait. - Design of the ranges trait - Understanding Niko's comments about variance (Note: for a long time I was using a straight up &mut Vec in the iterator, but I changed this to permit reusing the slice iterator). Previous PR and discussion: #23071
2015-04-28collections: Implement vec::drain(range) according to RFC 574Ulrik Sverdrup-81/+91
Old `.drain()` on vec is performed using `.drain(..)` now. `.drain(range)` is unstable and under feature(collections_drain) [breaking-change]