about summary refs log tree commit diff
path: root/library/alloc/src/collections
AgeCommit message (Collapse)AuthorLines
2025-09-29Use `Iterator::eq` and (dogfood) `eq_by` in compiler and libraryYotam Ofek-1/+1
2025-09-28Auto merge of #147042 - Noratrieb:untrack-caller-vec, r=tgross35bors-34/+0
Remove most `#[track_caller]` from allocating Vec methods They cause significant binary size overhead while contributing little value. closes rust-lang/rust#146963, see that issue for more details.
2025-09-26Update CURRENT_RUSTC_VERSION post-bumpMark Rousskov-10/+10
2025-09-25Remove most `#[track_caller]` from allocating Vec methodsNoratrieb-34/+0
They cause significant binary size overhead while contributing little value. Also removes them from the wrapping String methods that do not panic.
2025-09-25Rollup merge of #146859 - cammeresi:btree-alloc-20250920, r=joboetMatthias Krüger-2/+13
BTreeMap: Don't leak allocators when initializing nodes Memory was allocated via `Box::leak` and thence intended to be tracked and deallocated manually, but the allocator was also leaked, not tracked, and never dropped. Now it is dropped immediately. According to my reading of the `Allocator` trait, if a copy of the allocator remains live, then its allocations must remain live. Since the B-tree has a copy of the allocator that will only be dropped after the nodes, it's safe to not store the allocator in each node (which would be a much more intrusive change). Fixes: rust-lang/rust#106203
2025-09-24BTreeMap: Don't leak allocators when initializing nodesSidney Cammeresi-2/+13
Memory was allocated via `Box::leak` and thence intended to be tracked and deallocated manually, but the allocator was also leaked, not tracked, and never dropped. Now it is dropped immediately. According to my reading of the `Allocator` trait, if a copy of the allocator remains live, then its allocations must remain live. Since the B-tree has a copy of the allocator that will only be dropped after the nodes, it's safe to not store the allocator in each node (which would be a much more intrusive change).
2025-09-21btree InternalNode::new safety commentsMarijn Schouten-2/+3
2025-09-21Rollup merge of #146820 - cammeresi:alloc-20250919, r=tgross35Stuart Cook-2/+11
Add unstable attribute to BTreeMap-related allocator generics Although these types aren't directly constructable externally, since they're pub, I think this omission was an oversight. r? libs-api
2025-09-20docs: improve doc of some methods w/ rangestk-6/+6
2025-09-19Add unstable attribute to BTreeMap-related allocator genericsSidney Cammeresi-2/+11
Although these types aren't directly constructable externally, since they're pub, I think this omission was an oversight.
2025-09-19btree: safety comments for init and newMarijn Schouten-1/+7
2025-09-17Rollup merge of #144871 - Kivooeo:btree_entry_insert-stabilize, r=jhprattStuart Cook-4/+2
Stabilize `btree_entry_insert` feature This stabilises `btree_map::VacantEntry::insert_entry` and `btree_map::Entry::insert_entry`, following the FCP in [tracking issue](https://github.com/rust-lang/rust/issues/65225). New stable API: ```rust impl<'a, K: Ord, V, A: Allocator + Clone> Entry<'a, K, V, A> { pub fn insert_entry(self, value: V) -> OccupiedEntry<'a, K, V, A>; } impl<'a, K: Ord, V, A: Allocator + Clone> VacantEntry<'a, K, V, A> { pub fn insert_entry(mut self, value: V) -> OccupiedEntry<'a, K, V, A>; } ``` (FCP ended almost a year ago, so if it's needed for process we could rerun it) Closes: https://github.com/rust-lang/rust/issues/65225
2025-09-13Rollup merge of #145471 - rs-sac:extr, r=the8472Jacob Pratt-12/+10
Stabilize BTree{Map,Set}::extract_if Tracking issue: rust-lang/rust#70530 FCP completed: https://github.com/rust-lang/rust/issues/70530#issuecomment-3191454465 Closes: rust-lang/rust#70530
2025-09-01Constify conversion traitsltdk-2/+4
2025-08-27Stabilize BTree{Map,Set}::extract_ifSidney Cammeresi-12/+10
2025-08-26Rollup merge of #144373 - hkBst:remove-deprecated-1, r=jhprattGuillaume Gomez-4/+0
remove deprecated Error::description in impls [libs-api permission](https://github.com/rust-lang/libs-team/issues/615#issuecomment-3074045829) r? `@cuviper` or `@jhpratt`
2025-08-26remove deprecated Error::description in implsMarijn Schouten-4/+0
2025-08-24Prevent confusion with insertion-ordered maps.Marijn Schouten-2/+3
2025-08-24focus more on ordered aspect and restore old commentsMarijn Schouten-13/+45
2025-08-24Dial down detail of B-tree descriptionMarijn Schouten-24/+5
fixes 134088, though it is a shame to lose some of this wonderful detail.
2025-08-09`{BTree,Hash}Map`: add "`Entry` API" section headingAda Alakbarova-0/+2
2025-08-04Correct the use of `must_use` on btree::IterMutJonathan Brouwer-1/+1
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-08-04remove gatesKivooeo-4/+2
2025-07-30Implement push_mutBalt-15/+135
2025-07-22Rename `tests/codegen` into `tests/codegen-llvm`Guillaume Gomez-1/+1
2025-07-06Renamed retain_mut to retain on LinkedList as mentioned in the ACPJoshua Gentry-37/+2
2025-06-27BTreeSet: remove duplicated code by reusing `from_sorted_iter`Cheng Xu-3/+1
The method `BTreeSet::from_sorted_iter` was introduced in 49ccb7519f55bd117d2ab50b7a030637f380aec6, but it was not consistently used throughout the codebase. As a result, some code redundantly reimplemented its logic. This commit fixes the problem.
2025-06-18vec_deque tests: remove static mutMarijn Schouten-43/+13
2025-06-17Rollup merge of #142520 - hkBst:less-static-mut, r=tgross35Jacob Pratt-106/+55
alloc: less static mut + some cleanup I'm looking into https://github.com/rust-lang/rust/issues/125035 and would like some feedback on my approach.
2025-06-17linked_list tests: buff check_linksMarijn Schouten-40/+25
2025-06-16linked_list tests: less static mutMarijn Schouten-66/+30
2025-06-13Remove unneeded lifetimes from signature of BTreeSet::extract_ifDavid Tolnay-4/+4
2025-06-02Lightly tweak docs for BTree{Map,Set}::extract_ifSidney Cammeresi-7/+7
- Move explanations into comments to match style - Explain the second examples - Make variable names match the data structure
2025-05-27Unit test for Range parameter of `BTreeMap::extract_if`Sidney Cammeresi-0/+24
2025-05-27Update docs for new Range parameter to `BTreeMap::extract_if` etc.Sidney Cammeresi-4/+16
2025-05-27Update tests with Range parameter to `BTreeMap::extract_if` etc.Sidney Cammeresi-31/+31
2025-05-27Add Range parameter to `BTreeMap::extract_if` and `BTreeSet::extract_if`Sidney Cammeresi-19/+57
This change was requested in the btree_extract_if tracking issue: https://github.com/rust-lang/rust/issues/70530#issuecomment-2486566328
2025-05-25Rollup merge of #141108 - PaulDance:fix-extract_if-docs, r=Mark-SimulacrumJacob Pratt-10/+12
Docs(lib): Fix `extract_if` docs Various fixes to the documentation comments of the several `extract_if` collection methods available. It originally started with a small typo fix in `Vec`'s spotted when reading the 1.87 release notes, but then by looking at the others' for comparison in order to try determining what was the intended sentence, some inconsistencies were spotted. Therefore, some other changes are also proposed here to reduce these avoidable differences, going more and more nit-picky along the way. See the individual commits for more details about each change. `@rustbot` label T-libs A-collections A-docs
2025-05-21std: fix doctest and explain for as_slices and as_mut_slices in VecDequexizheyin-5/+28
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-05-17Docs(lib/extract_if): Unify example descriptionPaul Mabileau-1/+1
Signed-off-by: Paul Mabileau <paul.mabileau@harfanglab.fr>
2025-05-17Docs(lib/extract_if): Unify paragraph about elements mutationPaul Mabileau-2/+2
Take the one from `BTreeMap` that seems the best-worded and most precise among the available variations. Signed-off-by: Paul Mabileau <paul.mabileau@harfanglab.fr>
2025-05-17Docs(lib/extract_if): Unify paragraph about closure actionsPaul Mabileau-3/+3
Also fixes `HashSet`'s that incorrectly designated itself as a `list`. Signed-off-by: Paul Mabileau <paul.mabileau@harfanglab.fr>
2025-05-17Docs(lib/coll/btm): Split `extract_if`'s first sentence from the following onesPaul Mabileau-4/+6
This also seems like a small mistake: the first main sentence is put in the same paragraph as the other two following ones while other equivalents all have it split. Therefore, do the same here. Signed-off-by: Paul Mabileau <paul.mabileau@harfanglab.fr>
2025-05-07Rollup merge of #140668 - vkrivopalov:vecdeque-truncate-front, r=jhprattJacob Pratt-0/+67
Implement `VecDeque::truncate_front()` Tracking issue: #140667
2025-05-05Consistent trait bounds for ExtractIf Debug implsDavid Tolnay-15/+18
2025-05-05Implement `VecDeque::truncate_front()`Vladimir Krivopalov-0/+67
Tracking issue: #140667 Signed-off-by: Vladimir Krivopalov <vladimir.krivopalov@gmail.com>
2025-04-24Remove some unnecessary clones.Nicholas Nethercote-1/+1
I found these by grepping for `&[a-z_\.]*\.clone()`, i.e. expressions like `&a.b.clone()`, which are sometimes unnecessary clones, and also looking at clones nearby to cases like that.
2025-04-09intra-doc linkBoxy-1/+1
2025-04-09replace version placeholderBoxy-4/+4
2025-03-12Rollup merge of #138161 - HeroicKatora:heap-peek-mut-refresh, r=dtolnayMatthias Krüger-4/+78
Add PeekMut::refresh I'm not sure if this should go through ACP or not. BinaryHeap is not the most critical data structure in the standard library and it would be understandable if maintainer throughput is thus too limited to accept this PR without a proper design phase that ensures the required understanding of consequence over a longer time period. This aims to improve the useability of heaps for priority-based work queues. In certain scenarios, modifications on the most relevant or critical items are performed until a condition that determines the work items have been sufficiently addressed. For instance the criticality could be a deadline that is relaxed whenever some part of a work item is completed. Such a loop will repeatedly access the most critical item and put it back in a sorted position when it is complete. Crucially, due to the ordering invariant we know that all necessary work was performed when the completed item remains the most critical. Getting this information from the heap position avoids a (potentially more costly) check on the item state itself. A customized `drop` with boolean result would avoid up to two more comparisons performed in both the last no-op refresh and Drop code but this occurs once in each execution of the above scenario whereas refresh occurs any number of times. Also note that the comparison overhead of Drop is only taken if the element is mutably inspected to determine the end condition, i.e. not when refresh itself is the break condition.