about summary refs log tree commit diff
path: root/src/libstd/vec.rs
AgeCommit message (Collapse)AuthorLines
2014-05-07core: Move Option::expect to libstd from libcoreAlex Crichton-1/+1
See #14008 for more details
2014-05-07core: Inherit non-allocating slice functionalityAlex Crichton-0/+1
This commit adds a new trait, MutableVectorAllocating, which represents functions on vectors which can allocate. This is another extension trait to slices which should be removed once a lang item exists for the ~ allocation.
2014-05-06librustc: Remove `~EXPR`, `~TYPE`, and `~PAT` from the language, exceptPatrick Walton-3/+3
for `~str`/`~[]`. Note that `~self` still remains, since I forgot to add support for `Box<self>` before the snapshot. How to update your code: * Instead of `~EXPR`, you should write `box EXPR`. * Instead of `~TYPE`, you should write `Box<Type>`. * Instead of `~PATTERN`, you should write `box PATTERN`. [breaking-change]
2014-05-02Replace most ~exprs with 'box'. #11779Brian Anderson-2/+2
2014-05-01remove leftover obsolete string literalsDaniel Micay-3/+3
2014-04-28Fixed typo in std::vecAdolfo Ochagavía-1/+1
2014-04-21Fix misspellings in comments.Joseph Crail-2/+2
2014-04-18Replace all ~"" with "".to_owned()Richo Healey-6/+6
2014-04-18std: Make ~[T] no longer a growable vectorAlex Crichton-19/+19
This removes all resizability support for ~[T] vectors in preparation of DST. The only growable vector remaining is Vec<T>. In summary, the following methods from ~[T] and various functions were removed. Each method/function has an equivalent on the Vec type in std::vec unless otherwise stated. * slice::OwnedCloneableVector * slice::OwnedEqVector * slice::append * slice::append_one * slice::build (no replacement) * slice::bytes::push_bytes * slice::from_elem * slice::from_fn * slice::with_capacity * ~[T].capacity() * ~[T].clear() * ~[T].dedup() * ~[T].extend() * ~[T].grow() * ~[T].grow_fn() * ~[T].grow_set() * ~[T].insert() * ~[T].pop() * ~[T].push() * ~[T].push_all() * ~[T].push_all_move() * ~[T].remove() * ~[T].reserve() * ~[T].reserve_additional() * ~[T].reserve_exect() * ~[T].retain() * ~[T].set_len() * ~[T].shift() * ~[T].shrink_to_fit() * ~[T].swap_remove() * ~[T].truncate() * ~[T].unshift() * ~str.clear() * ~str.set_len() * ~str.truncate() Note that no other API changes were made. Existing apis that took or returned ~[T] continue to do so. [breaking-change]
2014-04-16Make Vec::clone and slice::to_owned failure-safeJames Miller-7/+4
2014-04-16Improve the copying code for slices and VecJames Miller-1/+20
2014-04-11std: Fix iteration over vectors of 0-size valuesAlex Crichton-2/+46
Previously, all slices derived from a vector whose values were of size 0 had a null pointer as the 'data' pointer on the slice. This caused first pointer to be yielded during iteration to always be the null pointer. Due to the null pointer optimization, this meant that the first return value was None, instead of Some(&T). This commit changes slice construction from a Vec instance to use a base pointer of 1 if the values have zero size. This means that the iterator will never return null, and the iteration will proceed appropriately. Closes #13467
2014-04-10libstd: Implement `StrBuf`, a new string buffer type like `Vec`, andPatrick Walton-1/+2
port all code over to use it.
2014-04-08Register new snapshotsAlex Crichton-0/+1
2014-04-04Added grow_fn and retain to VecMichael Darakananda-1/+64
2014-04-03std: override clone_from for Vec.Huon Wilson-4/+52
A vector can reuse its allocation (and the allocations/resources of any contained values) when cloning into an already-instantiated vector, so we might as well do so.
2014-04-01Reimplement Vec::push_all* with .extendStepan Koltsov-6/+2
It is shorter and also fixes missed reserve call.
2014-04-01Vec::reserve_exact should not shrinkStepan Koltsov-1/+1
reserve_exact should not shrink according to documentation.
2014-03-31std: Switch field privacy as necessaryAlex Crichton-5/+5
2014-03-31auto merge of #13221 : thestinger/rust/append, r=alexcrichtonbors-32/+32
These were only free functions on `~[T]` because taking self by-value used to be broken.
2014-03-31vec: convert `append` and `append_one` to methodsDaniel Micay-32/+32
These were only free functions on `~[T]` because taking self by-value used to be broken.
2014-03-30Rename `from_iterator` to `from_iter` for consistency.Brian Anderson-1/+1
2014-03-30Removed deprecated functions `map` and `flat_map` for vectors and slices.Marvin Löbel-7/+0
2014-03-25Changed `iter::Extendable` and `iter::FromIterator` to take a `Iterator` by ↵Marvin Löbel-6/+6
value
2014-03-24comm: Implement synchronous channelsAlex Crichton-7/+2
This commit contains an implementation of synchronous, bounded channels for Rust. This is an implementation of the proposal made last January [1]. These channels are built on mutexes, and currently focus on a working implementation rather than speed. Receivers for sync channels have select() implemented for them, but there is currently no implementation of select() for sync senders. Rust will continue to provide both synchronous and asynchronous channels as part of the standard distribution, there is no intent to remove asynchronous channels. This flavor of channels is meant to provide an alternative to asynchronous channels because like green tasks, asynchronous channels are not appropriate for all situations. [1] - https://mail.mozilla.org/pipermail/rust-dev/2014-January/007924.html
2014-03-23auto merge of #13096 : sstewartgallus/rust/cleanup-test-warnings, r=huonwbors-1/+0
2014-03-23This commit cleans up a few test warningsSteven Stewart-Gallus-1/+0
2014-03-23std: remove the `equals` method from `TotalEq`.Huon Wilson-6/+1
`TotalEq` is now just an assertion about the `Eq` impl of a type (i.e. `==` is a total equality if a type implements `TotalEq`) so the extra method is just confusing. Also, a new method magically appeared as a hack to allow deriving to assert that the contents of a struct/enum are also TotalEq, because the deriving infrastructure makes it very hard to do anything but create a trait method. (You didn't hear about this horrible work-around from me :(.)
2014-03-23Add Vec::mut_slice_from(), mut_slice_to(), and mut_split_at()Eunchong Yu-0/+122
2014-03-21auto merge of #13016 : huonw/rust/new-opt-vec, r=cmrbors-0/+13
Replace syntax::opt_vec with syntax::owned_slice The `owned_slice::OwnedSlice` is `(*T, uint)` (i.e. a direct equivalent to DSTs `~[T]`). This shaves two words off the old OptVec type; and also makes substituting in other implementations easy, by removing all the mutation methods. (And also everything that's very rarely/never used.)
2014-03-22Migrate all users of opt_vec to owned_slice, delete opt_vec.Huon Wilson-0/+13
syntax::opt_vec is now entirely unused, and so can go.
2014-03-21libstd: Add some methods to `Vec<T>`.Patrick Walton-17/+19
2014-03-20A couple of fixes to vec_ng docsSteven Fackler-14/+24
2014-03-20rename std::vec_ng -> std::vecDaniel Micay-0/+1353
Closes #12771
2014-03-20rename std::vec -> std::sliceDaniel Micay-4652/+0
Closes #12702
2014-03-08Removed DeepClone. Issue #12698.Michael Darakananda-19/+1
2014-03-07create a sensible comparison trait hierarchyDaniel Micay-2/+2
* `Ord` inherits from `Eq` * `TotalOrd` inherits from `TotalEq` * `TotalOrd` inherits from `Ord` * `TotalEq` inherits from `Eq` This is a partial implementation of #12517.
2014-03-04make `MutItems` iterator sound againDaniel Micay-9/+19
This become `Pod` when it was switched to using marker types.
2014-02-28std: Change assert_eq!() to use {} instead of {:?}Alex Crichton-43/+42
Formatting via reflection has been a little questionable for some time now, and it's a little unfortunate that one of the standard macros will silently use reflection when you weren't expecting it. This adds small bits of code bloat to libraries, as well as not always being necessary. In light of this information, this commit switches assert_eq!() to using {} in the error message instead of {:?}. In updating existing code, there were a few error cases that I encountered: * It's impossible to define Show for [T, ..N]. I think DST will alleviate this because we can define Show for [T]. * A few types here and there just needed a #[deriving(Show)] * Type parameters needed a Show bound, I often moved this to `assert!(a == b)` * `Path` doesn't implement `Show`, so assert_eq!() cannot be used on two paths. I don't think this is much of a regression though because {:?} on paths looks awful (it's a byte array). Concretely speaking, this shaved 10K off a 656K binary. Not a lot, but sometime significant for smaller binaries.
2014-02-28Improve vec `partition` and `partitioned` method doc.Felix S. Klock II-6/+5
Explicitly note in vec `partition` and `partitioned` that the left and right parts each map to satisfying and non-satisfying elements.
2014-02-27std: Small cleanup and test improvementAlex Crichton-1/+1
This weeds out a bunch of warnings building stdtest on windows, and it also adds a check! macro to the io::fs tests to help diagnose errors that are cropping up on windows platforms as well. cc #12516
2014-02-24std: make .swap_remove return Option<T>.Huon Wilson-20/+30
This is one of the last raw "indexing" method on vectors that returns `T` instead of the Option.
2014-02-23auto merge of #12311 : brson/rust/unstable, r=alexcrichtonbors-2/+2
With the stability attributes we can put public-but unstable modules next to others, so this moves `intrinsics` and `raw` out of the `unstable` module (and marks both as `#[experimental]`).
2014-02-23std: Move raw to std::rawBrian Anderson-2/+2
Issue #1457
2014-02-23Move std::{trie, hashmap} to libcollectionsAlex Crichton-6/+5
These two containers are indeed collections, so their place is in libcollections, not in libstd. There will always be a hash map as part of the standard distribution of Rust, but by moving it out of the standard library it makes libstd that much more portable to more platforms and environments. This conveniently also removes the stuttering of 'std::hashmap::HashMap', although 'collections::HashMap' is only one character shorter.
2014-02-22Move std::num::Integer to libnumBrendan Zabarauskas-3/+3
2014-02-20Mass rename if_ok! to try!Alex Crichton-3/+3
This "bubble up an error" macro was originally named if_ok! in order to get it landed, but after the fact it was discovered that this name is not exactly desirable. The name `if_ok!` isn't immediately clear that is has much to do with error handling, and it doesn't look fantastic in all contexts (if if_ok!(...) {}). In general, the agreed opinion about `if_ok!` is that is came in as subpar. The name `try!` is more invocative of error handling, it's shorter by 2 letters, and it looks fitting in almost all circumstances. One concern about the word `try!` is that it's too invocative of exceptions, but the belief is that this will be overcome with documentation and examples. Close #12037
2014-02-20move extra::test to libtestLiigo Zhuang-1/+2
2014-02-15auto merge of #12298 : alexcrichton/rust/rustdoc-testing, r=sfacklerbors-4/+4
It's too easy to forget the `rust` tag to test something. Closes #11698
2014-02-15auto merge of #12272 : alexcrichton/rust/snapshot, r=kballardbors-4/+2
This notably contains the `extern mod` => `extern crate` change. Closes #9880