Skip to content

Commit 1e89646

Browse files
authored
Rollup merge of rust-lang#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 rust-lang/rust-clippy#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.
2 parents aa85a10 + 06e4365 commit 1e89646

File tree

2 files changed

+6
-0
lines changed
  • library
    • alloc/src/collections/btree
    • std/src/collections/hash

2 files changed

+6
-0
lines changed

library/alloc/src/collections/btree/map.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ pub(super) const MIN_LEN: usize = node::MIN_LEN_AFTER_SPLIT;
135135
/// ]);
136136
/// ```
137137
///
138+
/// ## `Entry` API
139+
///
138140
/// `BTreeMap` implements an [`Entry API`], which allows for complex
139141
/// methods of getting, setting, updating and removing keys and their values:
140142
///

library/std/src/collections/hash/map.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ use crate::ops::Index;
135135
/// ]);
136136
/// ```
137137
///
138+
/// ## `Entry` API
139+
///
138140
/// `HashMap` implements an [`Entry` API](#method.entry), which allows
139141
/// for complex methods of getting, setting, updating and removing keys and
140142
/// their values:
@@ -167,6 +169,8 @@ use crate::ops::Index;
167169
/// player_stats.entry("mana").and_modify(|mana| *mana += 200).or_insert(100);
168170
/// ```
169171
///
172+
/// ## Usage with custom key types
173+
///
170174
/// The easiest way to use `HashMap` with a custom key type is to derive [`Eq`] and [`Hash`].
171175
/// We must also derive [`PartialEq`].
172176
///

0 commit comments

Comments
 (0)