about summary refs log tree commit diff
path: root/src/libcollections/vec.rs
AgeCommit message (Collapse)AuthorLines
2015-01-03collections: fix falloutJorge Aparicio-10/+14
2015-01-02rollup merge of #20410: japaric/assoc-typesAlex Crichton-6/+8
Conflicts: src/liballoc/lib.rs src/libcollections/lib.rs src/libcollections/slice.rs src/libcore/ops.rs src/libcore/prelude.rs src/libcore/ptr.rs src/librustc/middle/traits/project.rs src/libstd/c_str.rs src/libstd/io/mem.rs src/libstd/io/mod.rs src/libstd/lib.rs src/libstd/path/posix.rs src/libstd/path/windows.rs src/libstd/prelude.rs src/libstd/rt/exclusive.rs src/libsyntax/lib.rs src/test/compile-fail/issue-18566.rs src/test/run-pass/deref-mut-on-ref.rs src/test/run-pass/deref-on-ref.rs src/test/run-pass/dst-deref-mut.rs src/test/run-pass/dst-deref.rs src/test/run-pass/fixup-deref-mut.rs src/test/run-pass/issue-13264.rs src/test/run-pass/overloaded-autoderef-indexing.rs
2015-01-02core: use assoc types in `Deref[Mut]`Jorge Aparicio-3/+7
2015-01-02rollup merge of #20315: alexcrichton/std-syncAlex Crichton-1/+1
Conflicts: src/libstd/rt/exclusive.rs src/libstd/sync/barrier.rs src/libstd/sys/unix/pipe.rs src/test/bench/shootout-binarytrees.rs src/test/bench/shootout-fannkuch-redux.rs
2015-01-02rollup merge of #20377: alexcrichton/issue-20352Alex Crichton-3/+3
2015-01-02merge `*SliceExt` traits, use assoc types in `SliceExt`, `Raw[Mut]Ptr`Jorge Aparicio-3/+1
2015-01-02std: Stabilize the prelude moduleAlex Crichton-1/+3
This commit is an implementation of [RFC 503][rfc] which is a stabilization story for the prelude. Most of the RFC was directly applied, removing reexports. Some reexports are kept around, however: * `range` remains until range syntax has landed to reduce churn. * `Path` and `GenericPath` remain until path reform lands. This is done to prevent many imports of `GenericPath` which will soon be removed. * All `io` traits remain until I/O reform lands so imports can be rewritten all at once to `std::io::prelude::*`. This is a breaking change because many prelude reexports have been removed, and the RFC can be consulted for the exact list of removed reexports, as well as to find the locations of where to import them. [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0503-prelude-stabilization.md [breaking-change] Closes #20068
2015-01-01std: Enforce Unicode in fmt::WriterAlex Crichton-3/+3
This commit is an implementation of [RFC 526][rfc] which is a change to alter the definition of the old `fmt::FormatWriter`. The new trait, renamed to `Writer`, now only exposes one method `write_str` in order to guarantee that all implementations of the formatting traits can only produce valid Unicode. [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0526-fmt-text-writer.md One of the primary improvements of this patch is the performance of the `.to_string()` method by avoiding an almost-always redundant UTF-8 check. This is a breaking change due to the renaming of the trait as well as the loss of the `write` method, but migration paths should be relatively easy: * All usage of `write` should move to `write_str`. If truly binary data was being written in an implementation of `Show`, then it will need to use a different trait or an altogether different code path. * All usage of `write!` should continue to work as-is with no modifications. * All usage of `Show` where implementations just delegate to another should continue to work as-is. [breaking-change] Closes #20352
2015-01-01std: Second pass stabilization of syncAlex Crichton-1/+1
This pass performs a second pass of stabilization through the `std::sync` module, avoiding modules/types that are being handled in other PRs (e.g. mutexes, rwlocks, condvars, and channels). The following items are now stable * `sync::atomic` * `sync::atomic::ATOMIC_BOOL_INIT` (was `INIT_ATOMIC_BOOL`) * `sync::atomic::ATOMIC_INT_INIT` (was `INIT_ATOMIC_INT`) * `sync::atomic::ATOMIC_UINT_INIT` (was `INIT_ATOMIC_UINT`) * `sync::Once` * `sync::ONCE_INIT` * `sync::Once::call_once` (was `doit`) * C == `pthread_once(..)` * Boost == `call_once(..)` * Windows == `InitOnceExecuteOnce` * `sync::Barrier` * `sync::Barrier::new` * `sync::Barrier::wait` (now returns a `bool`) * `sync::Semaphore::new` * `sync::Semaphore::acquire` * `sync::Semaphore::release` The following items remain unstable * `sync::SemaphoreGuard` * `sync::Semaphore::access` - it's unclear how this relates to the poisoning story of mutexes. * `sync::TaskPool` - the semantics of a failing task and whether a thread is re-attached to a thread pool are somewhat unclear, and the utility of this type in `sync` is question with respect to the jobs of other primitives. This type will likely become stable or move out of the standard library over time. * `sync::Future` - futures as-is have yet to be deeply re-evaluated with the recent core changes to Rust's synchronization story, and will likely become stable in the future but are unstable until that time comes. [breaking-change]
2014-12-30rollup merge of #20061: aturon/stab-2-vec-sliceAlex Crichton-779/+687
Conflicts: src/libcollections/slice.rs src/libcollections/vec.rs src/libstd/sys/windows/os.rs
2014-12-30Fallout from stabilizationAaron Turon-32/+29
2014-12-30Stabilize cmpAaron Turon-3/+10
This patch marks `PartialEq`, `Eq`, `PartialOrd`, and `Ord` as `#[stable]`, as well as the majorify of manual implementaitons of these traits. The traits match the [reform RFC](https://github.com/rust-lang/rfcs/pull/439). Along the way, two changes are made: * The recently-added type parameters for `Ord` and `Eq` are removed. These were mistakenly added while adding them to `PartialOrd` and `PartialEq`, but they don't make sense given the laws that are required for (and use cases for) `Ord` and `Eq`. * More explicit laws are added for `PartialEq` and `PartialOrd`, connecting them to their associated mathematical concepts. In the future, many of the impls should be generalized; see since generalizing later is not a breaking change. [breaking-change]
2014-12-30Adjustments from reviewAaron Turon-1/+1
2014-12-30Second pass stabilization: vecAaron Turon-762/+676
This commit takes a second pass through the `vec` module to stabilize its API. The changes are as follows: **Stable**: * `dedup` * `from_raw_parts` * `insert` * `into_iter` * `is_empty` * `remove` * `reserve_exact` * `reserve` * `retain` * `swap_remove` * `truncate` **Deprecated**: * `from_fn`, `from_elem`, `grow_fn` and `grow`, all deprecated in favor of iterators. See https://github.com/rust-lang/rfcs/pull/509 * `partition`, `partitioned`, deprecated in favor of a new, more general iterator consumer called `partition`. * `unzip`, deprecated in favor of a new, more general iterator consumer called `unzip`. A few remaining methods are left at experimental status. [breaking-change]
2014-12-28libcollections: impl Send/Sync for Vec.Luqman Aden-0/+3
2014-12-28libcore: Don't impl RawPtr* traits for NonZero.Luqman Aden-1/+1
2014-12-28Don't expose NonZero through libstd.Luqman Aden-1/+2
2014-12-28libcore: Make it unsafe to create NonZero and impl Deref.Luqman Aden-26/+20
2014-12-28libcollections: Use NonZero in Vec.Luqman Aden-25/+32
2014-12-26Rename `UniquePtr` to `Unique`Flavio Percoco-10/+10
Mostly following the convention in RFC 356
2014-12-26Rename `OwnedPtr` to `UniquePtr`Flavio Percoco-10/+10
2014-12-26Require types to opt-in SyncFlavio Percoco-26/+28
2014-12-22Renaming of the Iter types as in RFC #344Florian Wilkens-9/+9
libcore: slice::Items -> slice::Iter, slice::MutItems -> slice::IterMut libcollections: *::Items -> *::Iter, *::MoveItems -> *::IntoIter, *::MutItems -> *::IterMut This is of course a [breaking-change].
2014-12-21Test fixes and rebase conflictsAlex Crichton-0/+1
2014-12-21rollup merge of #19972: alexcrichton/snapshotsAlex Crichton-14/+0
Conflicts: src/libcollections/string.rs src/libcollections/vec.rs src/snapshots.txt
2014-12-21rollup merge of #20070: aturon/stab-2-cloneAlex Crichton-1/+1
This patch marks `clone` stable, as well as the `Clone` trait, but leaves `clone_from` unstable. The latter will be decided by the beta. The patch also marks most manual implementations of `Clone` as stable, except where the APIs are otherwise deprecated or where there is uncertainty about providing `Clone`. r? @alexcrichton
2014-12-21rollup merge of #20044: csouth3/vec-resizeAlex Crichton-0/+27
This PR adds `resize()` to `Vec` in accordance with RFC 509.
2014-12-21rollup merge of #19965: japaric/remove-wrong-addAlex Crichton-9/+0
TL;DR I wrongly implemented these two ops, namely `"prefix" + "suffix".to_string()` gives back `"suffixprefix"`. Let's remove them. The correct implementation of these operations (`lhs.clone().push_str(rhs.as_slice())`) is really wasteful, because the lhs has to be cloned and the rhs gets moved/consumed just to be dropped (no buffer reuse). For this reason, I'd prefer to drop the implementation instead of fixing it. This leaves us with the fact that you'll be able to do `String + &str` but not `&str + String`, which may be unexpected. r? @aturon Closes #19952
2014-12-21auto merge of #19946 : cgaebel/rust/hashmap-drain-iter, r=gankrobors-3/+147
It is useful to move all the elements out of a hashmap without deallocating the underlying buffer. It came up in IRC, and this patch implements it as `drain`. r? @Gankro cc: @frankmcsherry
2014-12-20Stabilize cloneAaron Turon-1/+1
This patch marks `clone` stable, as well as the `Clone` trait, but leaves `clone_from` unstable. The latter will be decided by the beta. The patch also marks most manual implementations of `Clone` as stable, except where the APIs are otherwise deprecated or where there is uncertainty about providing `Clone`.
2014-12-20Fix fallout of removing import_shadowing in tests.Eduard Burtescu-5/+3
2014-12-20Fix the fallout of removing feature(import_shadowing).Eduard Burtescu-1/+0
2014-12-19Reform power_of_two methods for perf increase & semantic change to consider ↵Aaron Liblong-14/+4
0 not a power of 2. Vec panics when attempting to reserve capacity > int::MAX (uint::MAX / 2).
2014-12-19Implement resize for VecChase Southwood-0/+27
This commit adds `resize` to `Vec` in accordance with RFC 509.
2014-12-19Register new snapshotsAlex Crichton-15/+0
This does not yet start the movement to rustc-serialize. That detail is left to a future PR.
2014-12-18[collections] Adds `drain`: a way to sneak out the elements while clearing.Clark Gaebel-3/+147
It is useful to move all the elements out of some collections without deallocating the underlying buffer. It came up in IRC, and this patch implements it as `drain`. This has been discussed as part of RFC 509. r? @Gankro cc: @frankmcsherry
2014-12-18librustc: Always parse `macro!()`/`macro![]` as expressions if notPatrick Walton-5/+5
followed by a semicolon. This allows code like `vec![1i, 2, 3].len();` to work. This breaks code that uses macros as statements without putting semicolons after them, such as: fn main() { ... assert!(a == b) assert!(c == d) println(...); } It also breaks code that uses macros as items without semicolons: local_data_key!(foo) fn main() { println("hello world") } Add semicolons to fix this code. Those two examples can be fixed as follows: fn main() { ... assert!(a == b); assert!(c == d); println(...); } local_data_key!(foo); fn main() { println("hello world") } RFC #378. Closes #18635. [breaking-change]
2014-12-17Remove wrong `&str + String` and `&[T] + Vec<T>` implementationsJorge Aparicio-9/+0
2014-12-17rollup merge of #19943: steveklabnik/doc_std_vecAlex Crichton-74/+105
Random improvements to the `std::vec` docs.
2014-12-17rollup merge of #19902: alexcrichton/second-pass-memAlex Crichton-0/+1
This commit stabilizes the `mem` and `default` modules of std.
2014-12-16Improve docs for std::vecSteve Klabnik-74/+105
2014-12-15Move hash module from collections to coreSteven Fackler-0/+8
2014-12-15std: Second pass stabilization of `default`Alex Crichton-0/+1
This commit performs a second pass stabilization of the `std::default` module. The module was already marked `#[stable]`, and the inheritance of `#[stable]` was removed since this attribute was applied. This commit adds the `#[stable]` attribute to the trait definition and one method name, along with all implementations found in the standard distribution.
2014-12-16auto merge of #19747 : alexcrichton/rust/slice-one-trait, r=brsonbors-1/+1
This commit collapses the various prelude traits for slices into just one trait: * SlicePrelude/SliceAllocPrelude => SliceExt * CloneSlicePrelude/CloneSliceAllocPrelude => CloneSliceExt * OrdSlicePrelude/OrdSliceAllocPrelude => OrdSliceExt * PartialEqSlicePrelude => PartialEqSliceExt
2014-12-14std: Collapse SlicePrelude traitsAlex Crichton-1/+1
This commit collapses the various prelude traits for slices into just one trait: * SlicePrelude/SliceAllocPrelude => SliceExt * CloneSlicePrelude/CloneSliceAllocPrelude => CloneSliceExt * OrdSlicePrelude/OrdSliceAllocPrelude => OrdSliceExt * PartialEqSlicePrelude => PartialEqSliceExt
2014-12-13libcollections: add commutative version of `Vec`/`String` additionJorge Aparicio-0/+9
2014-12-13libcollections: Vec<T> + &[T]Jorge Aparicio-0/+12
2014-12-13libcollections: use unboxed closures in `Vec` methodsJorge Aparicio-6/+6
2014-12-11auto merge of #19377 : tbu-/rust/pr_mapinplace_fixzerosized_test, r=sfacklerbors-0/+29
2014-12-08Change 'Example' to 'Examples' throughout collections' rustdocs.jbranchaud-30/+32