about summary refs log tree commit diff
path: root/src/libcollections
AgeCommit message (Collapse)AuthorLines
2014-12-09Add a proper `Hash` implementation for `VecMap`Tobias Bucher-0/+37
Also re-add the previously deleted test with an additional test that would have failed before, when the hash function depended on the capacity.
2014-12-09rollup merge of #19626: bluss/string-extend-strAlex Crichton-0/+44
Strings iterate to both char and &str, so it is natural it can also be extended or collected from an iterator of &str. Apart from the trait implementations, `Extend<char>` is updated to use the iterator size hint, and the test added tests both the char and the &str versions of Extend and FromIterator.
2014-12-09rollup merge of #19622: steveklabnik/fix_ringbuf_docAlex Crichton-5/+1
https://botbot.me/mozilla/rust/2014-12-07/?msg=27003846&page=20
2014-12-09rollup merge of #19592: jbranchaud/add-btreemap-iter-doctestAlex Crichton-0/+18
I'm interested in including doctests for `BTreeMap`'s `iter_mut` and `into_iter` methods in this PR as well, but I am not sure of the best way to demonstrate/test what they do for the doctests.
2014-12-09Clean up `libcollections::VecMap`Tobias Bucher-54/+35
- Introduce a named type for the return type of `VecMap::move_iter` - Rename all type parameters to `V` for "Value". - Remove unnecessary call to an `Option::unwrap`, use pattern matching instead. - Remove incorrect `Hash` implementation which took the `VecMap`'s capacity into account. This is a [breaking-change], however whoever used the `Hash` implementation relied on an incorrect implementation.
2014-12-09Add a doctest for the std::string::as_string method.jbranchaud-0/+13
Change Example to Examples. Add a doctest that better demonstrates the utility of as_string. Update the doctest example to use String instead of &String.
2014-12-09auto merge of #19644 : pcwalton/rust/oibit3, r=nikomatsakisbors-17/+54
2014-12-08Change 'Example' to 'Examples' throughout collections' rustdocs.jbranchaud-283/+286
2014-12-08librustc: Make `Copy` opt-in.Niko Matsakis-17/+54
This change makes the compiler no longer infer whether types (structures and enumerations) implement the `Copy` trait (and thus are implicitly copyable). Rather, you must implement `Copy` yourself via `impl Copy for MyType {}`. A new warning has been added, `missing_copy_implementations`, to warn you if a non-generic public type has been added that could have implemented `Copy` but didn't. For convenience, you may *temporarily* opt out of this behavior by using `#![feature(opt_out_copy)]`. Note though that this feature gate will never be accepted and will be removed by the time that 1.0 is released, so you should transition your code away from using it. This breaks code like: #[deriving(Show)] struct Point2D { x: int, y: int, } fn main() { let mypoint = Point2D { x: 1, y: 1, }; let otherpoint = mypoint; println!("{}{}", mypoint, otherpoint); } Change this code to: #[deriving(Show)] struct Point2D { x: int, y: int, } impl Copy for Point2D {} fn main() { let mypoint = Point2D { x: 1, y: 1, }; let otherpoint = mypoint; println!("{}{}", mypoint, otherpoint); } This is the backwards-incompatible part of #13231. Part of RFC #3. [breaking-change]
2014-12-08auto merge of #19574 : erickt/rust/vec-reserve, r=alexcrichtonbors-4/+5
(I don't understand why this works, and so I don't quite trust this yet. I'm pushing it up to see if anyone else can replicate this performance increase) Somehow llvm is able to optimize this version of Vec::reserve into dramatically faster than the old version. In micro-benchmarks this was 2-10 times faster. It also reduce my Rust compile time from 41 minutes to 27 minutes. Closes #19281.
2014-12-08auto merge of #19306 : steveklabnik/rust/gh19269, r=nikomatsakis,brsonbors-8/+2
Fixes #19269. /cc @thestinger @mahkoh @mitsuhiko
2014-12-08auto merge of #19555 : ↵bors-0/+26
jbranchaud/rust/add-doctests-for-key-values-of-btreemap, r=Gankro
2014-12-08auto merge of #19378 : japaric/rust/no-as-slice, r=alexcrichtonbors-193/+190
Now that we have an overloaded comparison (`==`) operator, and that `Vec`/`String` deref to `[T]`/`str` on method calls, many `as_slice()`/`as_mut_slice()`/`to_string()` calls have become redundant. This patch removes them. These were the most common patterns: - `assert_eq(test_output.as_slice(), "ground truth")` -> `assert_eq(test_output, "ground truth")` - `assert_eq(test_output, "ground truth".to_string())` -> `assert_eq(test_output, "ground truth")` - `vec.as_mut_slice().sort()` -> `vec.sort()` - `vec.as_slice().slice(from, to)` -> `vec.slice(from_to)` --- Note that e.g. `a_string.push_str(b_string.as_slice())` has been left untouched in this PR, since we first need to settle down whether we want to favor the `&*b_string` or the `b_string[]` notation. This is rebased on top of #19167 cc @alexcrichton @aturon
2014-12-08auto merge of #19561 : csouth3/rust/treeset-bitops, r=Gankrobors-1/+125
Implement the `BitOr`, `BitAnd`, `BitXor`, and `Sub` traits from `std::ops` for TreeSet. The behavior of these operator overloads is consistent with [RFC 235](https://github.com/rust-lang/rfcs/blob/master/text/0235-collections-conventions.md#combinations). r? @Gankro
2014-12-07string: Add test for FromIterator<&str> and Extend<&str>bluss-2/+9
2014-12-07string: Add test for FromIterator<char> and Extend<char>bluss-0/+14
2014-12-07string: Implement FromIterator<&str> and Extend<&str> for Stringbluss-0/+21
&str is a "particle" of a string already, see the graphemes iterator, so it seems natural that we should be able to use it with Extend.
2014-12-07string: Use the iterator size_hint() in .extend()bluss-0/+2
2014-12-07Remove mention of Dequeue in collections docs.Steve Klabnik-5/+1
https://botbot.me/mozilla/rust/2014-12-07/?msg=27003846&page=20
2014-12-07auto merge of #19488 : jbranchaud/rust/add-btree-set-doctests, r=alexcrichtonbors-0/+66
There is already a test for `union` in the test namespace, but this commit adds a doctest that will appear in the rustdocs. Someone on IRC said, *Write doctests!*, so here I am. I am not sure this is the best way to demonstrate the behavior of the union function, so I am open to suggestions for improving this. If I am on the right track I'd be glad to include similar doctests for `intersection`, `difference`, etc.
2014-12-06libcollections: remove unnecessary `to_string()` callsJorge Aparicio-36/+36
2014-12-06libcollections: remove unnecessary `as_mut_slice()` callsJorge Aparicio-32/+32
2014-12-06libcollections: remove unnecessary `as_slice()` callsJorge Aparicio-126/+123
2014-12-05Add a doctest for BTreeMap's iter method.jbranchaud-0/+18
2014-12-05Implement BitOps for TreeSetChase Southwood-1/+125
2014-12-05Utilize fewer reexportsCorey Farwell-2/+4
In regards to: https://github.com/rust-lang/rust/issues/19253#issuecomment-64836729 This commit: * Changes the #deriving code so that it generates code that utilizes fewer reexports (in particur Option::* and Result::*), which is necessary to remove those reexports in the future * Changes other areas of the codebase so that fewer reexports are utilized
2014-12-05Add doctests for union, diff, sym_diff, and intersection.jbranchaud-0/+66
Add a rustdoc test for union to exhibit how it is used. There is already a test for union in the test namespace, but this commit adds a doctest that will appear in the rustdocs. Add a doctest for the difference function. Add a doctest for the symmetric_difference function. Add a doctest for the intersection function. Update the union et al. doctests based on @Gankro's comments. Make the union et al. doctests a bit more readable.
2014-12-05Add doctests for keys() and values() of the BTreeMap collection.jbranchaud-0/+26
Update keys() and values() for BTreeMap based on @Gankro's comments. Assign keys and values to variables before doing assertion.
2014-12-05collections: dramatically speed up Vec::reserve with magicErick Tryzelaar-4/+5
Somehow llvm is able to optimize this version of Vec::reserve into dramatically faster than the old version. In micro-benchmarks this was 2-10 times faster. It also shaved 14 minutes off of rust's compile times. Closes #19281.
2014-12-05Merge remote-tracking branch 'csouth3/trieset-bitops' into rollup-2014_12_03Corey Richardson-0/+60
Conflicts: src/libcollections/trie/set.rs
2014-12-05Implement BitOps for TrieSetChase Southwood-1/+125
2014-12-05rollup merge of #19528: aliblong/add_vecmap_capacityCorey Richardson-0/+16
Part of #18424 Adds `capacity()` function to VecMap, as per the collections reform. (Salvaged from #19516, #19523, while we await an RFC regarding `reserve`/`reserve_index` for `VecMap`)
2014-12-05rollup merge of #19518: csouth3/trieset-bitopsCorey Richardson-1/+65
Implement the `BitOr`, `BitAnd`, `BitXor`, and `Sub` traits from `std::ops` for TrieSet. The behavior of these operator overloads is consistent with [RFC 235](https://github.com/rust-lang/rfcs/blob/master/text/0235-collections-conventions.md#combinations).
2014-12-04Implement BitOps for TrieSetChase Southwood-1/+65
2014-12-04Add capacity() to VecMapAaron Liblong-0/+16
Changed capacity() tag to unstable and fixed doc assert
2014-12-03Deprecate EquivJorge Aparicio-2/+5
2014-12-03Fix falloutJorge Aparicio-20/+22
2014-12-03Overload the `==` operatorJorge Aparicio-5/+103
- String == &str == CowString - Vec == &[T] == &mut [T] == [T, ..N] == CowVec - InternedString == &str
2014-12-01Pop on binary heaps does not have constant time complexity.Jim Apple-2/+2
pop calls siftdown, siftdown calls siftdown_range, and siftdown_range loops on an index that can start as low as 0 and approximately doubles each iteration.
2014-11-29Add test for #18908Tobias Bucher-0/+29
2014-11-27impl Str for CowStringSean McArthur-0/+7
This implementation existed on MaybeOwned, but has been lost in the transition to Cows. Let's put it back.
2014-11-27auto merge of #19343 : sfackler/rust/less-special-attrs, r=alexcrichtonbors-1/+0
Descriptions and licenses are handled by Cargo now, so there's no reason to keep these attributes around.
2014-11-26More test fixes and rebase conflicts!Alex Crichton-2/+2
2014-11-26rollup merge of #19329: steveklabnik/doc_style_cleanup2Alex Crichton-52/+50
2014-11-26/*! -> //!Steve Klabnik-52/+50
Sister pull request of https://github.com/rust-lang/rust/pull/19288, but for the other style of block doc comment.
2014-11-26rollup merge of #19330: csouth3/binaryheap-iterAlex Crichton-0/+17
There's no reason that BinaryHeap's iterator can't implement DoubleEnded and ExactSize, so add these implementations.
2014-11-26rollup merge of #19308: thestinger/oomAlex Crichton-0/+1
Closes #19305
2014-11-26rollup merge of #19296: csouth3/trieset-unionAlex Crichton-1/+268
TrieSet doesn't yet have union, intersection, difference, and symmetric difference functions implemented. Luckily, TrieSet is largely similar to TreeSet, so I was able to reference the implementations of these functions in the latter, and adapt them as necessary to make them work for TrieSet. One thing that I thought was interesting is that the Iterator yielded by `iter()` for TrieSet iterates over the set's values directly rather than references to the values (whereas I think in most cases I see the Iterator given by `iter()` iterating over immutable references), so for consistency within TrieSet's interface, all of these Iterators also iterate over the values directly. Let me know if all of these should be instead iterating over references.
2014-11-26rollup merge of #19288: steveklabnik/doc_style_cleanupAlex Crichton-21/+19
This is considered good convention. This is about half of them in total, I just don't want an impossible to land patch. :smile:
2014-11-26rollup merge of #19287: alexcrichton/issue-19272Alex Crichton-1/+1
At the same time remove the `pub use` of the variants in favor of accessing through the enum type itself. This is a breaking change as the `Found` and `NotFound` variants must now be imported through `BinarySearchResult` instead of just `std::slice`. [breaking-change] Closes #19271