about summary refs log tree commit diff
path: root/library/alloc/src/collections/btree/map/entry.rs
AgeCommit message (Collapse)AuthorLines
2025-09-19Add unstable attribute to BTreeMap-related allocator genericsSidney Cammeresi-1/+6
Although these types aren't directly constructable externally, since they're pub, I think this omission was an oversight.
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-08-26remove deprecated Error::description in implsMarijn Schouten-4/+0
2025-08-04remove gatesKivooeo-4/+2
2024-11-27Add `BTreeSet` entry APIs to match `HashSet`Josh Stone-0/+5
* `fn get_or_insert(&mut self, value: T) -> &T` * `fn get_or_insert_with<Q: ?Sized, F>(&mut self, value: &Q, f: F) -> &T` * `fn entry(&mut self, value: T) -> Entry<'_, T, A>` (+ `Entry` APIs)
2024-11-14btree: add `{Entry,VacantEntry}::insert_entry`Josh Stone-30/+75
This matches the recently-stabilized methods on `HashMap` entries. I've reused tracking issue #65225 for now, but we may want to split it.
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-1/+1
2024-07-29Reformat `use` declarations.Nicholas Nethercote-3/+2
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-26Fix doc nitsJohn Arundel-0/+1
Many tiny changes to stdlib doc comments to make them consistent (for example "Returns foo", rather than "Return foo", per RFC1574), adding missing periods, paragraph breaks, backticks for monospace style, and other minor nits. https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md#appendix-a-full-conventions-text
2024-03-25lib: fix some unnecessary_cast clippy lintklensy-1/+1
warning: casting raw pointers to the same type and constness is unnecessary (`*mut V` -> `*mut V`) --> library\alloc\src\collections\btree\map\entry.rs:357:31 | 357 | let val_ptr = root.borrow_mut().push(self.key, value) as *mut V; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `root.borrow_mut().push (self.key, value)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast warning: casting to the same type is unnecessary (`usize` -> `usize`) --> library\alloc\src\ffi\c_str.rs:411:56 | 411 | let slice = slice::from_raw_parts_mut(ptr, len as usize); | ^^^^^^^^^^^^ help: try: `len` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast warning: casting raw pointers to the same type and constness is unnecessary (`*mut T` -> `*mut T`) --> library\alloc\src\slice.rs:516:25 | 516 | (buf.as_mut_ptr() as *mut T).add(buf.len()), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `buf.as_mut_ptr()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast warning: casting raw pointers to the same type and constness is unnecessary (`*mut T` -> `*mut T`) --> library\alloc\src\slice.rs:537:21 | 537 | (buf.as_mut_ptr() as *mut T).add(buf.len()), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `buf.as_mut_ptr()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast warning: casting raw pointers to the same type and constness is unnecessary (`*const ()` -> `*const ()`) --> library\alloc\src\task.rs:151:13 | 151 | waker as *const (), | ^^^^^^^^^^^^^^^^^^ help: try: `waker` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast warning: casting raw pointers to the same type and constness is unnecessary (`*const ()` -> `*const ()`) --> library\alloc\src\task.rs:323:13 | 323 | waker as *const (), | ^^^^^^^^^^^^^^^^^^ help: try: `waker` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast warning: casting to the same type is unnecessary (`usize` -> `usize`) --> library\std\src\sys_common\net.rs:110:21 | 110 | assert!(len as usize >= mem::size_of::<c::sockaddr_in>()); | ^^^^^^^^^^^^ help: try: `len` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast warning: casting to the same type is unnecessary (`usize` -> `usize`) --> library\std\src\sys_common\net.rs:116:21 | 116 | assert!(len as usize >= mem::size_of::<c::sockaddr_in6>()); | ^^^^^^^^^^^^ help: try: `len` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
2024-02-22Add `rustc_confusables` annotations to some stdlib APIsEsteban Küber-0/+3
Help with common API confusion, like asking for `push` when the data structure really has `append`. ``` error[E0599]: no method named `size` found for struct `Vec<{integer}>` in the current scope --> $DIR/rustc_confusables_std_cases.rs:17:7 | LL | x.size(); | ^^^^ | help: you might have meant to use `len` | LL | x.len(); | ~~~ help: there is a method with a similar name | LL | x.resize(); | ~~~~~~ ``` #59450
2023-02-01BTreeMap: Change internal insert function to return a handleAmanieu d'Antras-19/+21
This is a prerequisite for cursor support for `BTreeMap`.
2022-09-26remove cfg(bootstrap)Pietro Albini-1/+0
2022-08-22Move error trait into coreJane Losare-Lusby-0/+11
2022-06-17comments explaining why we have and don't have ManuallyDropRalf Jung-0/+2
2022-06-16btree: avoid forcing the allocator to be a referenceRalf Jung-19/+21
2022-06-14BTreeMap: Add alloc paramJacob Hughes-23/+45
2022-06-08BTree: tweak internal commentsStein Somers-4/+5
2022-03-09BTreeMap::entry: Avoid allocating if no insertionFrank King-13/+25
2022-03-07BTree: remove dead data needlessly complicating insertStein Somers-3/+3
2021-10-15Add #[must_use] to remaining alloc functionsJohn Kugelman-0/+2
2021-10-10Add #[must_use] to conversions that move selfJohn Kugelman-0/+1
2021-07-15Added diagnostic items to structs and traits for ClippyxFrednet-0/+1
2021-03-04Add tracking issue for map_try_insert.Mara Bos-3/+3
2021-03-04Implement Error for OccupiedError.Mara Bos-0/+13
2021-03-04Improve Debug implementations of OccupiedError.Mara Bos-2/+3
2021-03-04Add BTreeMap::try_insert and btree_map::OccupiedError.Mara Bos-0/+21
2021-02-24library: Normalize safety-for-unsafe-block commentsMiguel Ojeda-2/+2
Almost all safety comments are of the form `// SAFETY:`, so normalize the rest and fix a few of them that should have been a `/// # Safety` section instead. Furthermore, make `tidy` only allow the uppercase form. While currently `tidy` only checks `core`, it is a good idea to prevent `core` from drifting to non-uppercase comments, so that later we can start checking `alloc` etc. too. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2020-12-19Rollup merge of #78083 - ChaiTRex:master, r=m-ou-seYuki Okushi-5/+7
Stabilize or_insert_with_key Stabilizes the `or_insert_with_key` feature from https://github.com/rust-lang/rust/issues/71024. This allows inserting key-derived values when a `HashMap`/`BTreeMap` entry is vacant. The difference between this and `.or_insert_with(|| ... )` is that this provides a reference to the key to the closure after it is moved with `.entry(key_being_moved)`, avoiding the need to copy or clone the key.
2020-12-07Removed spurious linebreak from new documentationChai T. Rex-1/+1
2020-12-07Improved documentation for HashMap/BTreeMap Entry's .or_insert_with_key methodChai T. Rex-3/+6
2020-12-01Update rustc version that or_insert_with_key landedChai T. Rex-1/+1
2020-11-28BTreeMap: try to enhance various comments & local identifiersStein Somers-1/+1
2020-11-18BTreeMap: reuse NodeRef as Root, keep BoxedNode for edges only, ban UniqueStein Somers-1/+1
2020-10-18Stabilize or_insert_with_keyChai T. Rex-2/+1
2020-10-12BTreeMap: refactor Entry out of map.rs into its own fileJacob Hughes-0/+475
btree/map.rs is approaching the 3000 line mark, splitting out the entry code buys about 500 lines of headroom