about summary refs log tree commit diff
path: root/src/libcollections
AgeCommit message (Collapse)AuthorLines
2014-11-02refactor libcollections as part of collection reformAlexis Beingessner-1620/+1715
* Moves multi-collection files into their own directory, and splits them into seperate files * Changes exports so that each collection has its own module * Adds underscores to public modules and filenames to match standard naming conventions (that is, treemap::{TreeMap, TreeSet} => tree_map::TreeMap, tree_set::TreeSet) * Renames PriorityQueue to BinaryHeap * Renames SmallIntMap to VecMap * Miscellanious fallout fixes [breaking-change]
2014-11-02auto merge of #18456 : gamazeps/rust/issue18449, r=thestingerbors-9/+6
Made the fact that rodata is a section of the executable more explicit Closes #18449
2014-11-01bubble up out-of-memory errors from liballocDaniel Micay-0/+3
This makes the low-level allocation API suitable for use cases where out-of-memory conditions need to be handled. Closes #18292 [breaking-change]
2014-11-01collections: Remove all collections traitsAlex Crichton-1268/+1927
As part of the collections reform RFC, this commit removes all collections traits in favor of inherent methods on collections themselves. All methods should continue to be available on all collections. This is a breaking change with all of the collections traits being removed and no longer being in the prelude. In order to update old code you should move the trait implementations to inherent implementations directly on the type itself. Note that some traits had default methods which will also need to be implemented to maintain backwards compatibility. [breaking-change] cc #18424
2014-10-31DOC: improves the str type explanationgamazeps-9/+6
Closes #18449
2014-10-31DSTify HashJorge Aparicio-17/+22
- The signature of the `*_equiv` methods of `HashMap` and similar structures have changed, and now require one less level of indirection. Change your code from: ``` hashmap.find_equiv(&"Hello"); hashmap.find_equiv(&&[0u8, 1, 2]); ``` to: ``` hashmap.find_equiv("Hello"); hashmap.find_equiv(&[0u8, 1, 2]); ``` - The generic parameter `T` of the `Hasher::hash<T>` method have become `Sized?`. Downstream code must add `Sized?` to that method in their implementations. For example: ``` impl Hasher<FnvState> for FnvHasher { fn hash<T: Hash<FnvState>>(&self, t: &T) -> u64 { /* .. */ } } ``` must be changed to: ``` impl Hasher<FnvState> for FnvHasher { fn hash<Sized? T: Hash<FnvState>>(&self, t: &T) -> u64 { /* .. */ } // ^^^^^^ } ``` [breaking-change]
2014-10-30rollup merge of #18445 : alexcrichton/index-mutAlex Crichton-66/+64
Conflicts: src/libcollections/vec.rs
2014-10-30rollup merge of #18398 : aturon/lint-conventions-2Alex Crichton-3/+3
Conflicts: src/libcollections/slice.rs src/libcore/failure.rs src/libsyntax/parse/token.rs src/test/debuginfo/basic-types-mut-globals.rs src/test/debuginfo/simple-struct.rs src/test/debuginfo/trait-pointers.rs
2014-10-30rollup merge of #18443 : alexcrichton/deref-vec-and-stringAlex Crichton-432/+25
2014-10-30collections: Enable IndexMut for some collectionsAlex Crichton-66/+64
This commit enables implementations of IndexMut for a number of collections, including Vec, RingBuf, SmallIntMap, TrieMap, TreeMap, and HashMap. At the same time this deprecates the `get_mut` methods on vectors in favor of using the indexing notation. cc #18424
2014-10-29collections: impl Deref for Vec/StringAlex Crichton-432/+25
This commit adds the following impls: impl<T> Deref<[T]> for Vec<T> impl<T> DerefMut<[T]> for Vec<T> impl Deref<str> for String This commit also removes all duplicated inherent methods from vectors and strings as implementations will now silently call through to the slice implementation. Some breakage occurred at std and beneath due to inherent methods removed in favor of those in the slice traits and std doesn't use its own prelude, cc #18424
2014-10-29Rename fail! to panic!Steve Klabnik-53/+53
https://github.com/rust-lang/rfcs/pull/221 The current terminology of "task failure" often causes problems when writing or speaking about code. You often want to talk about the possibility of an operation that returns a Result "failing", but cannot because of the ambiguity with task failure. Instead, you have to speak of "the failing case" or "when the operation does not succeed" or other circumlocutions. Likewise, we use a "Failure" header in rustdoc to describe when operations may fail the task, but it would often be helpful to separate out a section describing the "Err-producing" case. We have been steadily moving away from task failure and toward Result as an error-handling mechanism, so we should optimize our terminology accordingly: Result-producing functions should be easy to describe. To update your code, rename any call to `fail!` to `panic!` instead. Assuming you have not created your own macro named `panic!`, this will work on UNIX based systems: grep -lZR 'fail!' . | xargs -0 -l sed -i -e 's/fail!/panic!/g' You can of course also do this by hand. [breaking-change]
2014-10-28auto merge of #18291 : japaric/rust/dstify, r=aturonbors-27/+29
This PR changes the signature of several methods from `foo(self, ...)` to `foo(&self, ...)`/`foo(&mut self, ...)`, but there is no breakage of the usage of these methods due to the autoref nature of `method.call()`s. This PR also removes the lifetime parameter from some traits (`Trait<'a>` -> `Trait`). These changes break any use of the extension traits for generic programming, but those traits are not meant to be used for generic programming in the first place. In the whole rust distribution there was only one misuse of a extension trait as a bound, which got corrected (the bound was unnecessary and got removed) as part of this PR. I've kept the commits as small and self-contained as possible for reviewing sake, but I can squash them when the review is over. See this [table] to get an idea of what's left to be done. I've already DSTified [`Show`][show] and I'm working on `Hash`, but bootstrapping those changes seem to require a more recent snapshot (#18259 does the trick) r? @aturon cc #16918 [show]: https://github.com/japaric/rust/commits/show [table]: https://docs.google.com/spreadsheets/d/1MZ_iSNuzsoqeS-mtLXnj9m0hBYaH5jI8k9G_Ud8FT5g/edit?usp=sharing
2014-10-28Update code with new lint namesAaron Turon-3/+3
2014-10-28auto merge of #18254 : areski/rust/pr-fix-vec-doc-example, r=alexcrichtonbors-2/+8
- shrink_to_fit example is now more clear by asserting the capacity value - annotation [0, mid) changed for [0, mid]
2014-10-27DSTify [T]/str extension traitsJorge Aparicio-27/+29
This PR changes the signature of several methods from `foo(self, ...)` to `foo(&self, ...)`/`foo(&mut self, ...)`, but there is no breakage of the usage of these methods due to the autoref nature of `method.call()`s. This PR also removes the lifetime parameter from some traits (`Trait<'a>` -> `Trait`). These changes break any use of the extension traits for generic programming, but those traits are not meant to be used for generic programming in the first place. In the whole rust distribution there was only one misuse of a extension trait as a bound, which got corrected (the bound was unnecessary and got removed) as part of this PR. [breaking-change]
2014-10-27Test fixes and rebase conflicts from rollupAlex Crichton-1/+1
2014-10-27rollup merge of #18332 : jbcrail/fix-commentsAlex Crichton-11/+11
2014-10-27Add @thestinger comment explaining that shrink_to_fit might drop down as ↵areski-2/+4
close as possible but not to the minimun
2014-10-25Fix spelling mistakes in comments.Joseph Crail-11/+11
2014-10-24Make the Vec data structure layout match raw::Slice.Clark Gaebel-11/+11
Fixes #18302 r? @thestinger
2014-10-24Add a lint for not using field pattern shorthandsP1start-6/+6
Closes #17792.
2014-10-23Improved examples on Vec documentationareski-1/+5
- shrink_to_fit example is now more clear by asserting the capacity value
2014-10-19Remove a large amount of deprecated functionalityAlex Crichton-938/+88
Spring cleaning is here! In the Fall! This commit removes quite a large amount of deprecated functionality from the standard libraries. I tried to ensure that only old deprecated functionality was removed. This is removing lots and lots of deprecated features, so this is a breaking change. Please consult the deprecation messages of the deleted code to see how to migrate code forward if it still needs migration. [breaking-change]
2014-10-18auto merge of #18096 : Gankro/rust/ganksy-is-dum, r=steveklabnikbors-1/+1
Fixes #18010 *phew* that was a lot of work. :sweat:
2014-10-17auto merge of #18089 : gamazeps/rust/small-bitv-cleanup, r=alexcrichtonbors-3/+0
I was going to write some doc in order to remove the #[allow(missing_doc)] but there was actually none missing. I also removed a warning i didn't see in my last commit #18018 Linked to #18009
2014-10-16Fix broken link in libcollections docsAlexis Beingessner-1/+1
Fixes #18010
2014-10-16libcollections: Remove all uses of {:?}.Luqman Aden-14/+11
2014-10-16Remove libdebug and update tests.Luqman Aden-1/+0
2014-10-16Removes useless confs from bitv.rsgamazeps-3/+0
Linked to #18009
2014-10-16auto merge of #18067 : mahkoh/rust/immutableintslice, r=alexcrichtonbors-0/+1
There is also a second commit that adds them to the prelude.
2014-10-15auto merge of #17934 : pcwalton/rust/better-autoderef-fixup, r=pnkfelixbors-4/+3
librustc: Improve method autoderef/deref/index behavior more, and enable IndexMut on mutable vectors. This fixes a bug whereby the mutability fixups for method behavior were not kicking in after autoderef failed to happen at any level. It also adds support for `Index` to the fixer-upper. Closes #12825. r? @pnkfelix
2014-10-15export *IntSlice in libcollectionsJulian Orth-0/+1
2014-10-14auto merge of #18018 : gamazeps/rust/isuue16736, r=cmrbors-104/+105
Closes #16736 linked to #18009
2014-10-14librustc: Improve method autoderef/deref/index behavior more, and enablePatrick Walton-4/+3
`IndexMut` on mutable vectors. This fixes a bug whereby the mutability fixups for method behavior were not kicking in after autoderef failed to happen at any level. It also adds support for `Index` to the fixer-upper. Closes #12825.
2014-10-14Switches from uint to u32 in BitV and BitVSetFelix Raimundo-104/+105
Closes #16736 linked to #18009
2014-10-13rollup merge of #17970 : nodakai/cleanup-warningsAlex Crichton-45/+49
2014-10-13rollup merge of #17888 : gmfawcett/patch-1Alex Crichton-1/+1
2014-10-13Clean up rustc warnings.NODA, Kai-45/+49
compiletest: compact "linux" "macos" etc.as "unix". liballoc: remove a superfluous "use". libcollections: remove invocations of deprecated methods in favor of their suggested replacements and use "_" for a loop counter. libcoretest: remove invocations of deprecated methods; also add "allow(deprecated)" for testing a deprecated method itself. libglob: use "cfg_attr". libgraphviz: add a test for one of data constructors. libgreen: remove a superfluous "use". libnum: "allow(type_overflow)" for type cast into u8 in a test code. librustc: names of static variables should be in upper case. libserialize: v[i] instead of get(). libstd/ascii: to_lowercase() instead of to_lower(). libstd/bitflags: modify AnotherSetOfFlags to use i8 as its backend. It will serve better for testing various aspects of bitflags!. libstd/collections: "allow(deprecated)" for testing a deprecated method itself. libstd/io: remove invocations of deprecated methods and superfluous "use". Also add #[test] where it was missing. libstd/num: introduce a helper function to effectively remove invocations of a deprecated method. libstd/path and rand: remove invocations of deprecated methods and superfluous "use". libstd/task and libsync/comm: "allow(deprecated)" for testing a deprecated method itself. libsync/deque: remove superfluous "unsafe". libsync/mutex and once: names of static variables should be in upper case. libterm: introduce a helper function to effectively remove invocations of a deprecated method. We still see a few warnings about using obsoleted native::task::spawn() in the test modules for libsync. I'm not sure how I should replace them with std::task::TaksBuilder and native::task::NativeTaskBuilder (dependency to libstd?) Signed-off-by: NODA, Kai <nodakai@gmail.com>
2014-10-12auto merge of #17942 : JIghtuse/rust/master, r=alexcrichtonbors-12/+7
[breaking-change] Closes #17916
2014-10-11auto merge of #17801 : Gankro/rust/collections-stuff, r=sfacklerbors-18/+140
I previously avoided `#[inline]`ing anything assuming someone would come in and explain to me where this would be appropriate. Apparently no one *really* knows, so I'll just go the opposite way an inline everything assuming someone will come in and yell at me that such-and-such shouldn't be `#[inline]`. ================== For posterity, iteration comparisons: ``` test btree::map::bench::iter_20 ... bench: 971 ns/iter (+/- 30) test btree::map::bench::iter_1000 ... bench: 29445 ns/iter (+/- 480) test btree::map::bench::iter_100000 ... bench: 2929035 ns/iter (+/- 21551) test treemap::bench::iter_20 ... bench: 530 ns/iter (+/- 66) test treemap::bench::iter_1000 ... bench: 26287 ns/iter (+/- 825) test treemap::bench::iter_100000 ... bench: 7650084 ns/iter (+/- 356711) test trie::bench_map::iter_20 ... bench: 646 ns/iter (+/- 265) test trie::bench_map::iter_1000 ... bench: 43556 ns/iter (+/- 5014) test trie::bench_map::iter_100000 ... bench: 12988002 ns/iter (+/- 139676) ``` As you can see `btree` "scales" much better than `treemap`. `triemap` scales quite poorly. Note that *completely* different results are given if the elements are inserted in order from the range [0, size]. In particular, TrieMap *completely* dominates in the sorted case. This suggests adding benches for both might be worthwhile. However unsorted is *probably* the more "normal" case, so I consider this "good enough" for now.
2014-10-11Remove into_vec method from &[T]Boris Egorov-12/+7
[breaking-change] Closes #17916
2014-10-10Register new snapshotsAlex Crichton-85/+0
Also convert a number of `static mut` to just a plain old `static` and remove some unsafe blocks.
2014-10-10improve the performance of the vec![] macroDaniel Micay-2/+2
Closes #17865
2014-10-10implement Box<[T]> <-> Vec<T> conversionsDaniel Micay-0/+47
2014-10-10vec: minor cleanupDaniel Micay-2/+1
2014-10-10auto merge of #17853 : alexcrichton/rust/issue-17718, r=pcwaltonbors-4/+4
This change is an implementation of [RFC 69][rfc] which adds a third kind of global to the language, `const`. This global is most similar to what the old `static` was, and if you're unsure about what to use then you should use a `const`. The semantics of these three kinds of globals are: * A `const` does not represent a memory location, but only a value. Constants are translated as rvalues, which means that their values are directly inlined at usage location (similar to a #define in C/C++). Constant values are, well, constant, and can not be modified. Any "modification" is actually a modification to a local value on the stack rather than the actual constant itself. Almost all values are allowed inside constants, whether they have interior mutability or not. There are a few minor restrictions listed in the RFC, but they should in general not come up too often. * A `static` now always represents a memory location (unconditionally). Any references to the same `static` are actually a reference to the same memory location. Only values whose types ascribe to `Sync` are allowed in a `static`. This restriction is in place because many threads may access a `static` concurrently. Lifting this restriction (and allowing unsafe access) is a future extension not implemented at this time. * A `static mut` continues to always represent a memory location. All references to a `static mut` continue to be `unsafe`. This is a large breaking change, and many programs will need to be updated accordingly. A summary of the breaking changes is: * Statics may no longer be used in patterns. Statics now always represent a memory location, which can sometimes be modified. To fix code, repurpose the matched-on-`static` to a `const`. static FOO: uint = 4; match n { FOO => { /* ... */ } _ => { /* ... */ } } change this code to: const FOO: uint = 4; match n { FOO => { /* ... */ } _ => { /* ... */ } } * Statics may no longer refer to other statics by value. Due to statics being able to change at runtime, allowing them to reference one another could possibly lead to confusing semantics. If you are in this situation, use a constant initializer instead. Note, however, that statics may reference other statics by address, however. * Statics may no longer be used in constant expressions, such as array lengths. This is due to the same restrictions as listed above. Use a `const` instead. [breaking-change] Closes #17718 [rfc]: https://github.com/rust-lang/rfcs/pull/246
2014-10-09auto merge of #17891 : brson/rust/verbump, r=alexcrichtonbors-1/+1
2014-10-09auto merge of #17558 : kaseyc/rust/fix_bitvset_union, r=aturonbors-57/+131
Updates the other_op function shared by the union/intersect/difference/symmetric_difference -with functions to fix an issue where certain elements would not be present in the result. To fix this, when other op is called, we resize self's nbits to account for any new elements that may be added to the set. Example: ```rust let mut a = BitvSet::new(); let mut b = BitvSet::new(); a.insert(0); b.insert(5); a.union_with(&b); println!("{}", a); //Prints "{0}" instead of "{0, 5}" ```
2014-10-09Use the same html_root_url for all docsBrian Anderson-1/+1