summary refs log tree commit diff
path: root/src/libcollections/vec.rs
AgeCommit message (Collapse)AuthorLines
2016-08-22Make `vec::IntoIter` covariant againAndrew Paseltiner-6/+9
Closes #35721
2016-08-11Introduce `as_mut_slice` method on `std::vec::IntoIter` struct.Corey Farwell-9/+29
2016-08-11Introduce `as_slice` method on `std::vec::IntoIter` struct.Corey Farwell-3/+22
Similar to the `as_slice` method on `core::slice::Iter` struct.
2016-08-02Add doc example for VecGuillaume Gomez-0/+19
2016-07-28Auto merge of #34951 - tomgarcia:covariant-vec, r=brsonbors-5/+6
Make vec::Drain and binary_heap::Drain covariant I removed all mutable pointers/references, and added covariance tests similar to the ones in #32635. It builds and passes the tests, but I noticed that there weren't any tests of Drain's behaviour (at least not in libcollectionstest), so I'm not sure if my changes accidently broke Drain's behaviour. Should I add some tests for that (and if so, what should the tests include)?
2016-07-23Fix incorrect 'memory leak' example for `Vec::set_len`.Corey Farwell-3/+4
Example was written in https://github.com/rust-lang/rust/pull/34911 Issue was brought up in this comment: https://github.com/rust-lang/rust/commit/a005b2cd2ac679da7393e537aa05e2b7d32d36d5#commitcomment-18346958
2016-07-21Readding lifetime parameters and removing allocationThomas Garcia-23/+44
2016-07-21Rollup merge of #34930 - frewsxcv:vec-as-slice, r=steveklabnikGuillaume Gomez-0/+16
Add doc examples for `Vec::{as_slice,as_mut_slice}`. None
2016-07-21Rollup merge of #34911 - frewsxcv:vec-set-len, r=steveklabnikGuillaume Gomez-2/+30
Rewrite/expand doc examples for `Vec::set_len`. None
2016-07-21Make vec::Drain and binary_heap::Drain covariantThomas Garcia-43/+23
2016-07-19Add doc examples for `Vec::{as_slice,as_mut_slice}`.Corey Farwell-0/+16
2016-07-19Rewrite/expand doc examples for `Vec::set_len`.Corey Farwell-2/+30
2016-07-18Rollup merge of #34884 - shepmaster:from_raw_parts_doc, r=@nagisaSeo Sanghyeon-1/+7
Improve {String,Vec}::from_raw_parts documentation
2016-07-18Rollup merge of #34853 - frewsxcv:vec-truncate, r=GuillaumeGomezSeo Sanghyeon-1/+28
Partial rewrite/expansion of `Vec::truncate` documentation. None
2016-07-17Remove extraneous wordsJake Goulding-1/+1
2016-07-17Document from_raw_parts involves ownership transferJake Goulding-0/+6
2016-07-16Remove unnecessary indexing and deref in `Vec::as_mut_slice`.Corey Farwell-1/+1
2016-07-16Partial rewrite/expansion of `Vec::truncate` documentation.Corey Farwell-1/+28
2016-07-14Mention where `std::vec` structs originate from.Corey Farwell-0/+11
2016-06-23Use `len` instead of `size_hint` where appropiateTobias Bucher-1/+1
This makes it clearer that we're not just looking for a lower bound but rather know that the iterator is an `ExactSizeIterator`.
2016-05-25Point out the clone operation in summary line docs of `Vec::extend_from_slice`Liigo Zhuang-1/+1
2016-04-14Specialize `Extend` to `append` for `{LinkedList, Vec}`Andrew Paseltiner-0/+13
2016-03-28style: Use `iter` for IntoIterator parameter namesKamal Marhubi-4/+4
This commit standardizes the codebase on `iter` for parameters with IntoIterator bounds. Previously about 40% of IntoIterator parameters were named `iterable`, with most of the rest being named `iter`. There was a single place where it was named `iterator`.
2016-03-12std: Clean out deprecated APIsAlex Crichton-30/+1
Removes all unstable and deprecated APIs prior to the 1.8 release. All APIs that are deprecated in the 1.8 release are sticking around for the rest of this cycle. Some notable changes are: * The `dynamic_lib` module was moved into `rustc_back` as the compiler still relies on a few bits and pieces. * The `DebugTuple` formatter now special-cases an empty struct name with only one field to append a trailing comma.
2016-03-06Auto merge of #30884 - durka:inclusive-ranges, r=aturonbors-0/+32
This PR implements [RFC 1192](https://github.com/rust-lang/rfcs/blob/master/text/1192-inclusive-ranges.md), which is triple-dot syntax for inclusive range expressions. The new stuff is behind two feature gates (one for the syntax and one for the std::ops types). This replaces the deprecated functionality in std::iter. Along the way I simplified the desugaring for all ranges. This is my first contribution to rust which changes more than one character outside of a test or comment, so please review carefully! Some of the individual commit messages have more of my notes. Also thanks for putting up with my dumb questions in #rust-internals. - For implementing `std::ops::RangeInclusive`, I took @Stebalien's suggestion from https://github.com/rust-lang/rfcs/pull/1192#issuecomment-137864421. It seemed to me to make the implementation easier and increase type safety. If that stands, the RFC should be amended to avoid confusion. - I also kind of like @glaebhoerl's [idea](https://github.com/rust-lang/rfcs/pull/1254#issuecomment-147815299), which is unified inclusive/exclusive range syntax something like `x>..=y`. We can experiment with this while everything is behind a feature gate. - There are a couple of FIXMEs left (see the last commit). I didn't know what to do about `RangeArgument` and I haven't added `Index` impls yet. Those should be discussed/finished before merging. cc @Gankro since you [complained](https://www.reddit.com/r/rust/comments/3xkfro/what_happened_to_inclusive_ranges/cy5j0yq) cc #27777 #30877 rust-lang/rust#1192 rust-lang/rfcs#1254 relevant to #28237 (tracking issue)
2016-03-02Use ptr::drop_in_place in Vec::truncateUlrik Sverdrup-3/+4
2016-03-02Use ptr::drop_in_place in Vec::dropUlrik Sverdrup-8/+3
Directly use the drop glue for [T]. Still optimizes out in -O1 like with the `needs_drop` intrinsic.
2016-02-27add indexing with RangeInclusive in libcore and libcollectionsAlex Burka-0/+32
2016-02-24Add more explanation on vec typeGuillaume Gomez-0/+43
2016-02-17Implement `Clone` for `std::vec::IntoIter`Tobias Bucher-1/+11
2016-02-16Clarify contiguous memory array structure of vectors in documentationDirk Gadsden-3/+3
Closes #31554. Contributes to #29380.
2016-02-12doc: skipping (obvious) details here is worth making this more nice to readTshepang Lekhonkhobe-2/+2
2016-02-03Add `Cow::from` for `Vec` and slicesTobias Bucher-0/+14
Fixes #31354.
2016-01-16std: Stabilize APIs for the 1.7 releaseAlex Crichton-6/+5
This commit stabilizes and deprecates the FCP (final comment period) APIs for the upcoming 1.7 beta release. The specific APIs which changed were: Stabilized * `Path::strip_prefix` (renamed from `relative_from`) * `path::StripPrefixError` (new error type returned from `strip_prefix`) * `Ipv4Addr::is_loopback` * `Ipv4Addr::is_private` * `Ipv4Addr::is_link_local` * `Ipv4Addr::is_multicast` * `Ipv4Addr::is_broadcast` * `Ipv4Addr::is_documentation` * `Ipv6Addr::is_unspecified` * `Ipv6Addr::is_loopback` * `Ipv6Addr::is_unique_local` * `Ipv6Addr::is_multicast` * `Vec::as_slice` * `Vec::as_mut_slice` * `String::as_str` * `String::as_mut_str` * `<[T]>::clone_from_slice` - the `usize` return value is removed * `<[T]>::sort_by_key` * `i32::checked_rem` (and other signed types) * `i32::checked_neg` (and other signed types) * `i32::checked_shl` (and other signed types) * `i32::checked_shr` (and other signed types) * `i32::saturating_mul` (and other signed types) * `i32::overflowing_add` (and other signed types) * `i32::overflowing_sub` (and other signed types) * `i32::overflowing_mul` (and other signed types) * `i32::overflowing_div` (and other signed types) * `i32::overflowing_rem` (and other signed types) * `i32::overflowing_neg` (and other signed types) * `i32::overflowing_shl` (and other signed types) * `i32::overflowing_shr` (and other signed types) * `u32::checked_rem` (and other unsigned types) * `u32::checked_neg` (and other unsigned types) * `u32::checked_shl` (and other unsigned types) * `u32::saturating_mul` (and other unsigned types) * `u32::overflowing_add` (and other unsigned types) * `u32::overflowing_sub` (and other unsigned types) * `u32::overflowing_mul` (and other unsigned types) * `u32::overflowing_div` (and other unsigned types) * `u32::overflowing_rem` (and other unsigned types) * `u32::overflowing_neg` (and other unsigned types) * `u32::overflowing_shl` (and other unsigned types) * `u32::overflowing_shr` (and other unsigned types) * `ffi::IntoStringError` * `CString::into_string` * `CString::into_bytes` * `CString::into_bytes_with_nul` * `From<CString> for Vec<u8>` * `From<CString> for Vec<u8>` * `IntoStringError::into_cstring` * `IntoStringError::utf8_error` * `Error for IntoStringError` Deprecated * `Path::relative_from` - renamed to `strip_prefix` * `Path::prefix` - use `components().next()` instead * `os::unix::fs` constants - moved to the `libc` crate * `fmt::{radix, Radix, RadixFmt}` - not used enough to stabilize * `IntoCow` - conflicts with `Into` and may come back later * `i32::{BITS, BYTES}` (and other integers) - not pulling their weight * `DebugTuple::formatter` - will be removed * `sync::Semaphore` - not used enough and confused with system semaphores Closes #23284 cc #27709 (still lots more methods though) Closes #27712 Closes #27722 Closes #27728 Closes #27735 Closes #27729 Closes #27755 Closes #27782 Closes #27798
2015-12-18Auto merge of #30272 - tshepang:doc-drain, r=blussbors-6/+11
Second sentence actually repeats info from first sentence. "from start to end" also feels like it adds nothing. I also extended Vec::drain example.
2015-12-17doc: improve drain examples and remove secondary info from leading paragraphTshepang Lekhonkhobe-6/+11
2015-12-17Remove unused importsJeffrey Seyfried-1/+1
2015-12-09doc: these are just renames, so avoid duplicationTshepang Lekhonkhobe-15/+1
2015-12-05std: Stabilize APIs for the 1.6 releaseAlex Crichton-9/+45
This commit is the standard API stabilization commit for the 1.6 release cycle. The list of issues and APIs below have all been through their cycle-long FCP and the libs team decisions are listed below Stabilized APIs * `Read::read_exact` * `ErrorKind::UnexpectedEof` (renamed from `UnexpectedEOF`) * libcore -- this was a bit of a nuanced stabilization, the crate itself is now marked as `#[stable]` and the methods appearing via traits for primitives like `char` and `str` are now also marked as stable. Note that the extension traits themeselves are marked as unstable as they're imported via the prelude. The `try!` macro was also moved from the standard library into libcore to have the same interface. Otherwise the functions all have copied stability from the standard library now. * The `#![no_std]` attribute * `fs::DirBuilder` * `fs::DirBuilder::new` * `fs::DirBuilder::recursive` * `fs::DirBuilder::create` * `os::unix::fs::DirBuilderExt` * `os::unix::fs::DirBuilderExt::mode` * `vec::Drain` * `vec::Vec::drain` * `string::Drain` * `string::String::drain` * `vec_deque::Drain` * `vec_deque::VecDeque::drain` * `collections::hash_map::Drain` * `collections::hash_map::HashMap::drain` * `collections::hash_set::Drain` * `collections::hash_set::HashSet::drain` * `collections::binary_heap::Drain` * `collections::binary_heap::BinaryHeap::drain` * `Vec::extend_from_slice` (renamed from `push_all`) * `Mutex::get_mut` * `Mutex::into_inner` * `RwLock::get_mut` * `RwLock::into_inner` * `Iterator::min_by_key` (renamed from `min_by`) * `Iterator::max_by_key` (renamed from `max_by`) Deprecated APIs * `ErrorKind::UnexpectedEOF` (renamed to `UnexpectedEof`) * `OsString::from_bytes` * `OsStr::to_cstring` * `OsStr::to_bytes` * `fs::walk_dir` and `fs::WalkDir` * `path::Components::peek` * `slice::bytes::MutableByteVector` * `slice::bytes::copy_memory` * `Vec::push_all` (renamed to `extend_from_slice`) * `Duration::span` * `IpAddr` * `SocketAddr::ip` * `Read::tee` * `io::Tee` * `Write::broadcast` * `io::Broadcast` * `Iterator::min_by` (renamed to `min_by_key`) * `Iterator::max_by` (renamed to `max_by_key`) * `net::lookup_addr` New APIs (still unstable) * `<[T]>::sort_by_key` (added to mirror `min_by_key`) Closes #27585 Closes #27704 Closes #27707 Closes #27710 Closes #27711 Closes #27727 Closes #27740 Closes #27744 Closes #27799 Closes #27801 cc #27801 (doesn't close as `Chars` is still unstable) Closes #28968
2015-11-24rustfmt libcollectionsNick Cameron-57/+71
2015-11-18Add missing annotations and some testsVadim Petrochenkov-0/+6
2015-11-12libcollections: deny warnings in doctestsKevin Butler-0/+1
2015-11-08Fix outdated comment in Vec::from_iterStepan Koltsov-2/+1
Since commit 46068c9da, call to `reserve()` on empty vec allocates exactly requested capacity, so unroll of first iteration may help only with branch prediction.
2015-11-06Auto merge of #29643 - petrochenkov:stability5, r=alexcrichtonbors-1/+0
Also remove `stable` stability annotations from inherent impls (There will be a warning for useless stability annotations soon.) r? @Gankro
2015-11-06Remove stability annotations from trait impl itemsVadim Petrochenkov-1/+0
Remove `stable` stability annotations from inherent impls
2015-11-05vec: Remove old comment in Vec::dropUlrik Sverdrup-4/+0
This comment was leftover from an earlier revision of a PR, something that never was merged. There is no ZST special casing in Vec::drop.
2015-10-30don't use drop_in_place as an intrinsicAlexis Beingessner-2/+2
2015-10-30Auto merge of #29458 - tshepang:better, r=alexcrichtonbors-2/+3
I see that `extend()` is not called if new_len > len()
2015-10-29doc: fix and expand explanationTshepang Lekhonkhobe-2/+3
I see that `extend()` is not called if new_len > len()
2015-10-28Update docstring for truncateCameron Sun-2/+2
This documentation confused me when trying to use truncate on a project. Originally, it was unclear whether truncate removed the last `len` elements, or whether it cut down the vector to be exactly `len` elements long. The example was also ambiguous.