From c0a3e4802a06dd644c59aa7eed4af4bf437d3853 Mon Sep 17 00:00:00 2001 From: Ada Alakbarova Date: Sat, 9 Aug 2025 14:49:19 +0200 Subject: [PATCH 1/2] `{BTree,Hash}Map`: add "`Entry` API" section heading --- library/alloc/src/collections/btree/map.rs | 2 ++ library/std/src/collections/hash/map.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index acbbb6df9a5a5..c4e599222e501 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 edbdd0411457f..0c5d41bcee8be 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: From 06e43655bc57359ece7143d5cd31afc3a0744a59 Mon Sep 17 00:00:00 2001 From: Ada Alakbarova Date: Sat, 9 Aug 2025 19:41:10 +0200 Subject: [PATCH 2/2] `HashMap`: also add "Usage with custom key types" heading --- library/std/src/collections/hash/map.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs index 0c5d41bcee8be..15a7a770d1a87 100644 --- a/library/std/src/collections/hash/map.rs +++ b/library/std/src/collections/hash/map.rs @@ -169,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`]. ///