about summary refs log tree commit diff
diff options
context:
space:
mode:
authorStuart Cook <Zalathar@users.noreply.github.com>2025-08-10 19:45:54 +1000
committerGitHub <noreply@github.com>2025-08-10 19:45:54 +1000
commit461009dc939327b9fcb83fe39ae07bb76987fc0f (patch)
tree2126674713b7fbf6691491d432708f1472f43423
parenta4acb8aafa34878f337ec8b656ca4e26e9834db3 (diff)
parent06e43655bc57359ece7143d5cd31afc3a0744a59 (diff)
downloadrust-461009dc939327b9fcb83fe39ae07bb76987fc0f.tar.gz
rust-461009dc939327b9fcb83fe39ae07bb76987fc0f.zip
Rollup merge of #145162 - ada4a:hash_and_btree_map-add-entry-section, r=joshtriplett
`{BTree,Hash}Map`: add "`Entry` API" section heading

I wanted to link to an introduction of the `Entry` API to the help message of `clippy::map_entry` (see https://github.com/rust-lang/rust-clippy/issues/11598 for motivation), but I found the documentation on the `Entry` enum itself a bit short. On the other hand, `{BTree,Hash}Map` both have sections in their docs introducing the whole API and giving usage examples, and so I would like to link to that instead. For that, I introduce the "`Entry` API" section heading to both of them.

Do let me know whether you think this is the right approach.
-rw-r--r--library/alloc/src/collections/btree/map.rs2
-rw-r--r--library/std/src/collections/hash/map.rs4
2 files changed, 6 insertions, 0 deletions
diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs
index acbbb6df9a5..c4e599222e5 100644
--- a/library/alloc/src/collections/btree/map.rs
+++ b/library/alloc/src/collections/btree/map.rs
@@ -135,6 +135,8 @@ pub(super) const MIN_LEN: usize = node::MIN_LEN_AFTER_SPLIT;
 /// ]);
 /// ```
 ///
+/// ## `Entry` API
+///
 /// `BTreeMap` implements an [`Entry API`], which allows for complex
 /// methods of getting, setting, updating and removing keys and their values:
 ///
diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs
index edbdd041145..15a7a770d1a 100644
--- a/library/std/src/collections/hash/map.rs
+++ b/library/std/src/collections/hash/map.rs
@@ -135,6 +135,8 @@ use crate::ops::Index;
 /// ]);
 /// ```
 ///
+/// ## `Entry` API
+///
 /// `HashMap` implements an [`Entry` API](#method.entry), which allows
 /// for complex methods of getting, setting, updating and removing keys and
 /// their values:
@@ -167,6 +169,8 @@ use crate::ops::Index;
 /// player_stats.entry("mana").and_modify(|mana| *mana += 200).or_insert(100);
 /// ```
 ///
+/// ## Usage with custom key types
+///
 /// The easiest way to use `HashMap` with a custom key type is to derive [`Eq`] and [`Hash`].
 /// We must also derive [`PartialEq`].
 ///