about summary refs log tree commit diff
path: root/src/libstd/vec.rs
AgeCommit message (Collapse)AuthorLines
2014-05-27std: Rename strbuf operations to stringRicho Healey-2/+2
[breaking-change]
2014-05-27std: Remove String's to_ownedRicho Healey-6/+7
2014-05-24core: rename strbuf::StrBuf to string::StringRicho Healey-2/+2
[breaking-change]
2014-05-22libstd: Remove `~str` from all `libstd` modules except `fmt` and `str`.Patrick Walton-4/+4
2014-05-20core: Stabilize the mem moduleAlex Crichton-7/+9
Excluding the functions inherited from the cast module last week (with marked stability levels), these functions received the following treatment. * size_of - this method has become #[stable] * nonzero_size_of/nonzero_size_of_val - these methods have been removed * min_align_of - this method is now #[stable] * pref_align_of - this method has been renamed without the `pref_` prefix, and it is the "default alignment" now. This decision is in line with what clang does (see url linked in comment on function). This function is now #[stable]. * init - renamed to zeroed and marked #[stable] * uninit - marked #[stable] * move_val_init - renamed to overwrite and marked #[stable] * {from,to}_{be,le}{16,32,64} - all functions marked #[stable] * swap/replace/drop - marked #[stable] * size_of_val/min_align_of_val/align_of_val - these functions are marked #[unstable], but will continue to exist in some form. Concerns have been raised about their `_val` prefix. [breaking-change]
2014-05-15Make Vec.truncate() resilient against failure in DropKevin Ballard-5/+40
If a vector element fails in Drop, Vec needs to make sure it doesn't try to re-drop any elements it already dropped.
2014-05-11core: Remove the cast moduleAlex Crichton-34/+48
This commit revisits the `cast` module in libcore and libstd, and scrutinizes all functions inside of it. The result was to remove the `cast` module entirely, folding all functionality into the `mem` module. Specifically, this is the fate of each function in the `cast` module. * transmute - This function was moved to `mem`, but it is now marked as #[unstable]. This is due to planned changes to the `transmute` function and how it can be invoked (see the #[unstable] comment). For more information, see RFC 5 and #12898 * transmute_copy - This function was moved to `mem`, with clarification that is is not an error to invoke it with T/U that are different sizes, but rather that it is strongly discouraged. This function is now #[stable] * forget - This function was moved to `mem` and marked #[stable] * bump_box_refcount - This function was removed due to the deprecation of managed boxes as well as its questionable utility. * transmute_mut - This function was previously deprecated, and removed as part of this commit. * transmute_mut_unsafe - This function doesn't serve much of a purpose when it can be achieved with an `as` in safe code, so it was removed. * transmute_lifetime - This function was removed because it is likely a strong indication that code is incorrect in the first place. * transmute_mut_lifetime - This function was removed for the same reasons as `transmute_lifetime` * copy_lifetime - This function was moved to `mem`, but it is marked `#[unstable]` now due to the likelihood of being removed in the future if it is found to not be very useful. * copy_mut_lifetime - This function was also moved to `mem`, but had the same treatment as `copy_lifetime`. * copy_lifetime_vec - This function was removed because it is not used today, and its existence is not necessary with DST (copy_lifetime will suffice). In summary, the cast module was stripped down to these functions, and then the functions were moved to the `mem` module. transmute - #[unstable] transmute_copy - #[stable] forget - #[stable] copy_lifetime - #[unstable] copy_mut_lifetime - #[unstable] [breaking-change]
2014-05-10vec: factor out some deallocation codeDaniel Micay-9/+12
2014-05-10vec: move some code inside alloc_or_reallocDaniel Micay-7/+5
2014-05-10fix Vec<ZeroSizeType>Daniel Micay-2/+15
2014-05-10initial port of the exchange allocator to jemallocDaniel Micay-1/+1
In stage0, all allocations are 8-byte aligned. Passing a size and alignment to free is not yet implemented everywhere (0 size and 8 align are used as placeholders). Fixing this is part of #13994. Closes #13616
2014-05-10use jemalloc to implement Vec<T>Daniel Micay-27/+46
2014-05-08Move partition/partitioned/concat/connect tests back into sliceKevin Ballard-26/+4
There was no reason to remove them from slice. They're testing methods defined in slice, so that's where they belong. Leave vec with copies of the partition/partitioned tests because it has its own implementation of those methods.
2014-05-08Add a mechanism to convert from Vec<T> to ~[T]Kevin Ballard-1/+73
Add a new trait FromVec with one self-less method from_vec(). This is kind of like FromIterator, but it consumes a Vec<T>. It's only implemented for ~[T], but the idea is post-DST it can be implemented for any Boxed<[T]>.
2014-05-08Handle fallout for vector additionKevin Ballard-1/+11
Adding two vectors now results in a Vec<T> instead of a ~[T]. Implement Add on Vec<T>.
2014-05-08Move slice::raw::from_buf_raw() to vec::raw::from_buf()Kevin Ballard-1/+36
Change from_buf_raw() to return a Vec<T> instead of a ~[T]. As such, it belongs in vec, in the newly-created vec::raw module.
2014-05-08Rename slice::unzip() to vec::unzip()Kevin Ballard-0/+33
unzip() has nothing to do with slices, so it belongs in vec.
2014-05-08More fallout from removing FromIterator on ~[T]Kevin Ballard-0/+38
A few methods in slice that used to return ~[T] now return Vec<T>: - VectorVector.concat/connect_vec() returns Vec<T> - slice::unzip() returns (Vec<T>, Vec<U>) - ImmutableCloneableVector.partitioned() returns (Vec<T>, Vec<T>) - OwnedVector.partition() returns (Vec<T>, Vec<T>)
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