summary refs log tree commit diff
path: root/library/alloc/src/collections/vec_deque
AgeCommit message (Collapse)AuthorLines
2021-10-04Auto merge of #89144 - sexxi-goose:insig_stdlib, r=nikomatsakisbors-0/+1
2229: Mark insignificant dtor in stdlib I looked at all public [stdlib Drop implementations](https://doc.rust-lang.org/stable/std/ops/trait.Drop.html#implementors) and categorized them into Insigificant/Maybe/Significant Drop. Reasons are noted here: https://docs.google.com/spreadsheets/d/19edb9r5lo2UqMrCOVjV0fwcSdS-R7qvKNL76q7tO8VA/edit#gid=1838773501 One thing missing from this PR is tagging HashMap as insigificant destructor as that needs some discussion. r? `@Mark-Simulacrum` cc `@nikomatsakis`
2021-08-16Remove extra empty linesXuanwo-2/+0
Signed-off-by: Xuanwo <github@xuanwo.io>
2021-08-16Optimize unnecessary check in VecDeque::retainXuanwo-8/+59
Signed-off-by: Xuanwo <github@xuanwo.io>
2021-08-08Auto merge of #86879 - YohDeadfall:stabilize-vec-shrink-to, r=dtolnaybors-2/+1
Stabilize Vec<T>::shrink_to This PR stabilizes `shrink_to` feature and closes the corresponding issue. The second point was addressed already, and no `panic!` should occur. Closes #56431.
2021-08-08Bump shrink_to stabilization to Rust 1.56David Tolnay-1/+1
2021-08-07Auto merge of #87408 - kornelski:try_reserve_error, r=yaahcbors-1/+2
Hide allocator details from TryReserveError I think there's [no need for TryReserveError to carry detailed information](https://github.com/rust-lang/rust/issues/48043#issuecomment-825139280), but I wouldn't want that issue to delay stabilization of the `try_reserve` feature. So I'm proposing to stabilize `try_reserve` with a `TryReserveError` as an opaque structure, and if needed, expose error details later. This PR moves the `enum` to an unstable inner `TryReserveErrorKind` that lives under a separate feature flag. `TryReserveErrorKind` could possibly be left as an implementation detail forever, and the `TryReserveError` get methods such as `allocation_size() -> Option<usize>` or `layout() -> Option<Layout>` instead, or the details could be dropped completely to make try-reserve errors just a unit struct, and thus smaller and cheaper.
2021-08-05alloc: Use intra doc links for the reserve functionest31-1/+3
The sentence exists to highlight the existence of a performance footgun of repeated calls of the reserve_exact function.
2021-07-30Rollup merge of #87574 - cuviper:retain-examples, r=joshtriplettYuki Okushi-3/+4
Update the examples in `String` and `VecDeque::retain` The examples added in #60396 used a "clever" post-increment hack, unrelated to the actual point of the examples. That hack was found [confusing] in the users forum, and #81811 already changed the `Vec` example to use a more direct iterator. This commit changes `String` and `VecDeque` in the same way for consistency. [confusing]: https://users.rust-lang.org/t/help-understand-strange-expression/62858
2021-07-28Update the examples in `String` and `VecDeque::retain`Josh Stone-3/+4
The examples added in #60396 used a "clever" post-increment hack, unrelated to the actual point of the examples. That hack was found [confusing] in the users forum, and #81811 already changed the `Vec` example to use a more direct iterator. This commit changes `String` and `VecDeque` in the same way for consistency. [confusing]: https://users.rust-lang.org/t/help-understand-strange-expression/62858
2021-07-28Remove redundant bounds on get_unchecked for vec_deque iterators, and run fmtFrank Steffahn-10/+4
2021-07-28Add TrustedRandomAccessNoCoerce supertrait without requirements or ↵Frank Steffahn-4/+12
guarantees about subtype coercions Update all the TrustedRandomAccess impls to also implement the new supertrait
2021-07-25Auto merge of #86595 - a1phyr:allocator_api_for_vecdeque, r=Amanieubors-74/+137
Add support for custom allocator in `VecDeque` This follows the [roadmap](https://github.com/rust-lang/wg-allocators/issues/7) of the allocator WG to add custom allocators to collections. `@rustbot` modify labels: +A-allocators +T-libs
2021-07-24Auto merge of #84111 - bstrie:hashfrom, r=joshtriplettbors-0/+22
Stabilize `impl From<[(K, V); N]> for HashMap` (and friends) In addition to allowing HashMap to participate in Into/From conversion, this adds the long-requested ability to use constructor-like syntax for initializing a HashMap: ```rust let map = HashMap::from([ (1, 2), (3, 4), (5, 6) ]); ``` This addition is highly motivated by existing precedence, e.g. it is already possible to similarly construct a Vec from a fixed-size array: ```rust let vec = Vec::from([1, 2, 3]); ``` ...and it is already possible to collect a Vec of tuples into a HashMap (and vice-versa): ```rust let vec = Vec::from([(1, 2)]); let map: HashMap<_, _> = vec.into_iter().collect(); let vec: Vec<(_, _)> = map.into_iter().collect(); ``` ...and of course it is likewise possible to collect a fixed-size array of tuples into a HashMap ([but not vice-versa just yet](https://github.com/rust-lang/rust/issues/81615)): ```rust let arr = [(1, 2)]; let map: HashMap<_, _> = std::array::IntoIter::new(arr).collect(); ``` Therefore this addition seems like a no-brainer. As for any impl, this would be insta-stable.
2021-07-24Hide allocator details from TryReserveErrorKornel-1/+2
2021-07-24Update std_collections_from_array stability versionbstrie-1/+1
2021-07-23Add `#[unstable]` on new functionsBenoît du Garreau-2/+2
2021-07-23Add unstable attribute for `A` in `Drain` and `IntoIter`Benoît du Garreau-2/+9
2021-07-23Add support for custom allocator in `VecDeque`Benoît du Garreau-74/+130
2021-07-21Remove unsound TrustedRandomAccess implementationsFrank Steffahn-29/+1
Removes the implementations that depend on the user-definable trait `Copy`. Only fix regressions to ensure merge in 1.55: Does not modify `vec::IntoIter`.
2021-07-06Stabilize Vec<T>::shrink_toYoh Deadfall-2/+1
2021-06-30impl From<[(K, V); N]> for std::collectionsbstrie-0/+22
2021-06-30Remove "length" doc aliasesAmanieu d'Antras-1/+0
2021-06-16Add doc(hidden) to all __iterator_get_uncheckedJacob Hoffman-Andrews-0/+3
This method on the Iterator trait is doc(hidden), and about half of implementations were doc(hidden). This adds the attribute to the remaining implementations.
2021-06-06Rollup merge of #85930 - mominul:array_into_iter, r=m-ou-seYuki Okushi-2/+1
Update standard library for IntoIterator implementation of arrays This PR partially resolves issue #84513 of updating the standard library part. I haven't found any remaining doctest examples which are using iterators over e.g. &i32 instead of just i32 in the standard library. Can anyone point me to them if there's remaining any? Thanks! r? ```@m-ou-se```
2021-06-02Stabilize VecDeque::partition_point.Mara Bos-2/+1
2021-06-02Bump vecdeque_binary_search stabilization to 1.54.Mara Bos-3/+3
2021-06-02Bumped `vecdeque_binary_search` stabilization version to 1.53.0SOFe-3/+3
2021-06-02Stabilize `vecdeque_binary_search`SOFe-7/+3
2021-06-02Replace IntoIter::new with IntoIterator::into_iter in stdMuhammad Mominul Huque-2/+1
2021-05-06Perf Experiment: Wait, what if I just skip the trait aliasScott McMurray-3/+3
2021-05-06Bootstrapping preparation for the libraryScott McMurray-3/+3
Since just `ops::Try` will need to change meaning.
2021-04-15VecDeque: Improve doc comments in binary search fnsVojtech Kral-5/+23
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2021-04-15VecDeque: Add partition_point() #78021Vojtech Kral-0/+45
2021-04-15VecDeque: binary_search_by(): return right away if hit found at back.first() ↵Vojtech Kral-1/+4
#78021
2021-03-21use BITS constantThe8472-1/+1
2021-03-21implement TrustedLen and TrustedRandomAccess for VecDeque iteratorsThe8472-3/+77
2021-03-17Fix overflowing length in Vec<ZST> to VecDequeJosh Stone-19/+33
`Vec` can hold up to `usize::MAX` ZST items, but `VecDeque` has a lower limit to keep its raw capacity as a power of two, so we should check that in `From<Vec<T>> for VecDeque<T>`. We can also simplify the capacity check for the remaining non-ZST case. Before this fix, the new test would fail on the length: ``` thread 'collections::vec_deque::tests::test_from_vec_zst_overflow' panicked at 'assertion failed: `(left == right)` left: `0`, right: `9223372036854775808`', library/alloc/src/collections/vec_deque/tests.rs:474:5 note: panic did not contain expected string panic message: `"assertion failed: `(left == right)`\n left: `0`,\n right: `9223372036854775808`"`, expected substring: `"capacity overflow"` ``` That was a result of `len()` using a mask `& (size - 1)` with the improper length. Now we do get a "capacity overflow" panic as soon as that `VecDeque::from(vec)` is attempted.
2021-02-12Rename `Range::ensure_subset_of` to `slice::range`dylni-1/+1
2021-02-12Fix possible soundness issue in `ensure_subset_of`dylni-1/+1
2021-02-12Improve design of `assert_len`dylni-1/+1
2021-01-26shrink_to shouldn't panic on len greater than capacityThom Wiggers-6/+4
2021-01-18Avoid hash_slice in VecDeque's Hash implementationKonrad Borowski-3/+47
Fixes #80303.
2021-01-15Rollup merge of #80834 - bugadani:vecdeque, r=oli-obkYuki Okushi-5/+4
Remove unreachable panics from VecDeque::{front/back}[_mut] `VecDeque`'s `front`, `front_mut`, `back` and `back_mut` methods are implemented in terms of the index operator, which causes these functions to contain [unreachable panic calls](https://rust.godbolt.org/z/MTnq1o). This PR reimplements these methods in terms of `get[_mut]` instead.
2021-01-14Remove unreachable panics from VecDequeDániel Buga-5/+4
2021-01-11Add another test case for #79808Yuki Okushi-0/+15
Taken from #80293.
2020-12-28Rollup merge of #80448 - m-ou-se:deque-range-version, r=m-ou-seMara Bos-2/+2
Fix stabilization version of deque_range feature. See https://github.com/rust-lang/rust/pull/79022#issuecomment-751315315
2020-12-28Fix stabilization version of deque_range feature.Mara Bos-2/+2
2020-12-28Add "length" as doc alias to len methodsKonrad Borowski-0/+1
2020-12-26Auto merge of #79022 - SpyrosRoum:stabilize-deque_range, r=m-ou-sebors-6/+2
stabilize deque_range Make #74217 stable, stabilizing `VecDeque::range` and `VecDeque::range_mut`. Pr: #74099 r? `@m-ou-se`
2020-12-13fix typoJustus K-1/+1