summary refs log tree commit diff
path: root/src/libcollections/vec.rs
AgeCommit message (Collapse)AuthorLines
2015-06-30Avoid overflow in Vec::from_iterSteven Fackler-2/+3
Closes #26550
2015-06-30Make `align_of` behave like `min_align_of`.Huon Wilson-7/+7
This removes a footgun, since it is a reasonable assumption to make that pointers to `T` will be aligned to `align_of::<T>()`. This also matches the behaviour of C/C++. `min_align_of` is now deprecated. Closes #21611.
2015-06-17More test fixes and fallout of stability changesAlex Crichton-0/+2
2015-06-17std: Deprecate Vec::from_raw_bufAlex Crichton-0/+2
This function is more naturally expressed as slice::from_raw_buf plus a call to to_vec.
2015-06-17Fallout in tests and docs from feature renamingsAlex Crichton-4/+4
2015-06-17collections: Split the `collections` featureAlex Crichton-11/+22
This commit also deprecates the `as_string` and `as_slice` free functions in the `string` and `vec` modules.
2015-06-17Auto merge of #22681 - mzabaluev:extend-faster, r=huonwbors-39/+39
Instead of a fast branch with a sized iterator falling back to a potentially poorly optimized iterate-and-push loop, a single efficient loop can serve all cases. In my benchmark runs, I see some good gains, but also some regressions, possibly due to different inlining choices by the compiler. YMMV.
2015-06-11Auto merge of #26190 - Veedrac:no-iter, r=alexcrichtonbors-2/+2
Pull request for #26188.
2015-06-11Conver reborrows to .iter() calls where appropriateJoshua Landau-1/+1
2015-06-10Removed many pointless calls to *iter() and iter_mut()Joshua Landau-1/+1
2015-06-10Rollup merge of #26164 - tafia:early-dedup, r=GankroManish Goregaokar-1/+1
No need to dedup if there is only 1 element in the vec, can early return
2015-06-10early return if 1 elementJohann Tuffe-1/+1
No need to dedup if there is only 1 element in the vec, can early return
2015-06-09Exise 'unsafe pointer' in favor of 'raw pointer'Steve Klabnik-1/+1
Using two terms for one thing is confusing, these are called 'raw pointers' today.
2015-06-08Auto merge of #25989 - jooert:implement_rfc839, r=Gankrobors-0/+7
I had to use `impl<'a, V: Copy> Extend<(usize, &'a V)> for VecMap<V>` instead of `impl<'a, V: Copy> Extend<(&'a usize, &'a V)> for VecMap<V>` as that's what is needed for doing ```rust let mut a = VecMap::new(); let b = VecMap::new(); b.insert(1, "foo"); a.extend(&b) ``` I can squash the commits after review. r? @Gankro
2015-06-08Implement RFC 839Johannes Oertel-0/+7
Closes #25976.
2015-06-08Auto merge of #25823 - oli-obk:static_to_const_lint, r=alexcrichtonbors-1/+1
r? @eddyb
2015-06-07change some statics to constantsOliver 'ker' Schneider-1/+1
2015-06-06Remove many unneeded feature annotations in the docsSteve Klabnik-1/+1
When things get stabilized, they don't always have their docs updated to remove the gate.
2015-05-27Improve docs for Vec::as_slice and as_mut_sliceMatt Brubeck-1/+5
Fixes #25622.
2015-05-27Remove #[cfg(stage0)] items.Eduard Burtescu-71/+1
2015-05-22Make it clear that push is only amortized O(1)Brian Quinlan-1/+2
2015-05-19collections: Avoid unstable code in examples for VecUlrik Sverdrup-8/+4
2015-05-15Allow for better optimizations of iterators for zero-sized typesBjörn Steinbrink-0/+70
Using regular pointer arithmetic to iterate collections of zero-sized types doesn't work, because we'd get the same pointer all the time. Our current solution is to convert the pointer to an integer, add an offset and then convert back, but this inhibits certain optimizations. What we should do instead is to convert the pointer to one that points to an i8*, and then use a LLVM GEP instructions without the inbounds flag to perform the pointer arithmetic. This allows to generate pointers that point outside allocated objects without causing UB (as long as you don't dereference them), and it wraps around using two's complement, i.e. it behaves exactly like the wrapping_* operations we're currently using, with the added benefit of LLVM being able to better optimize the resulting IR.
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-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-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-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-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-02Override Iterator::count method in vec::IntoItersinkuu-0/+5
2015-05-01std: Remove index notation on slice iteratorsAlex Crichton-5/+4
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-28Register new snapshotsTamir Duberstein-6/+0
2015-04-28Auto merge of #24781 - bluss:vec-drain-range, r=alexcrichtonbors-78/+87
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-78/+87
Old `.drain()` on vec is performed using `.drain(..)` now. `.drain(range)` is unstable and under feature(collections_drain) [breaking-change]
2015-04-27Rollup merge of #24868 - tshepang:fix-vec-remove-doc, r=steveklabnikSteve Klabnik-1/+1
2015-04-27Rollup merge of #24848 - bluss:deref-string, r=alexcrichtonSteve Klabnik-0/+16
Improve example for as_string and add example for as_vec Provide a better example of `as_string` / `DerefString`'s unique capabilities. Use an example where (for an unspecified reason) you need a &String, and show how `as_string` solves the problem without needing an allocation.
2015-04-27doc: it is 'index', not 'i'Tshepang Lekhonkhobe-1/+1
2015-04-27collections: Improve example for as_string and as_vecUlrik Sverdrup-0/+16
2015-04-26Utilize `while let` instead of `loop` with `break` in doc-commentCorey Farwell-5/+1
2015-04-21Test fixes and rebase conflicts, round 1Alex Crichton-1/+1
2015-04-21rollup merge of #24636: alexcrichton/remove-deprecatedAlex Crichton-12/+0
Conflicts: src/libcore/result.rs
2015-04-21std: Remove deprecated AsOsStr/Str/AsSlice traitsAlex Crichton-12/+0
Cleaning out more deprecated items
2015-04-17std: Add Default/IntoIterator/ToOwned to the preludeAlex Crichton-35/+29
This is an implementation of [RFC 1030][rfc] which adds these traits to the prelude and additionally removes all inherent `into_iter` methods on collections in favor of the trait implementation (which is now accessible by default). [rfc]: https://github.com/rust-lang/rfcs/pull/1030 This is technically a breaking change due to the prelude additions and removal of inherent methods, but it is expected that essentially no code breaks in practice. [breaking-change] Closes #24538
2015-04-13pluralize doc comment verbs and add missing periodsAndrew Paseltiner-3/+3
2015-04-13Auto merge of #23849 - bcoopers:master, r=pnkfelixbors-6/+18
Right now, if the user requests to increase the vector size via reserve() or push_back() and the request brings the attempted memory above usize::MAX, we panic. With this change there is only a panic if the minimum requested memory that could meet the requirement is above usize::MAX- otherwise it simply requests its largest capacity possible, usize::MAX.
2015-04-12The panic! macro can't be called with a variable declaredbcoopers-3/+3
with "let" when building on stage0. So change the error message to a static const.
2015-04-10Changed the wording of the documentation for the insert method for Vec to be ↵Dominick Allen-2/+1
less confusing. Since 0 is the smallest number possible for usize, it doesn't make sense to mention it if it's already included, and it should be more clear that the length of the vector is a valid index with the new wording.
2015-04-03Remove unnecessary `Vec<_>` annotation from docsScott Olson-1/+1
This was brought up in IRC by a confused reader.
2015-03-31rollup merge of #23288: alexcrichton/issue-19470Alex Crichton-11/+11
This is a deprecated attribute that is slated for removal, and it also affects all implementors of the trait. This commit removes the attribute and fixes up implementors accordingly. The primary implementation which was lost was the ability to compare `&[T]` and `Vec<T>` (in that order). This change also modifies the `assert_eq!` macro to not consider both directions of equality, only the one given in the left/right forms to the macro. This modification is motivated due to the fact that `&[T] == Vec<T>` no longer compiles, causing hundreds of errors in unit tests in the standard library (and likely throughout the community as well). Closes #19470 [breaking-change]
2015-03-31rollup merge of #23908: aturon/stab-more-stragglersAlex Crichton-1/+1
* The `io::Seek` trait. * The `Iterator::{partition, unsip}` methods. * The `Vec::into_boxed_slice` method. * The `LinkedList::append` method. * The `{or_insert, or_insert_with` methods in the `Entry` APIs. r? @alexcrichton