Skip to content

Commit 431d660

Browse files
committed
fixup + bikeshed
1 parent 27faef4 commit 431d660

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

text/0000-entry_v3.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Occupied case into an `&mut V`. Usage looks like:
4848
```
4949

5050
```
51-
entry(key).get().unwrap_or_else(|entry| entry.insert(vec![])).push(val);
51+
map.entry(key).get().unwrap_or_else(|entry| entry.insert(vec![])).push(val);
5252
```
5353

5454
This is certainly *nicer*. No imports are needed, the Occupied case is handled, and we're closer
@@ -70,7 +70,6 @@ Replace `Entry::get` with the following two methods:
7070
}
7171
}
7272
73-
#[unstable(feature = "collections",
7473
/// Ensures a value is in the entry by inserting the result of the default function if empty,
7574
/// and returns a mutable reference to the value in the entry.
7675
pub fn default_with<F: FnOnce() -> V>(self. default: F) -> &'a mut V {
@@ -90,11 +89,11 @@ which allows the following:
9089

9190
```
9291
// vec![] doesn't even allocate, and is only 3 ptrs big.
93-
entry(key).default(vec![]).push(val);
92+
map.entry(key).default(vec![]).push(val);
9493
```
9594

9695
```
97-
let val = entry(key).default_with(|| expensive(big, data));
96+
let val = map.entry(key).default_with(|| expensive(big, data));
9897
```
9998

10099
Look at all that ergonomics. *Look at it*. This pushes us more into the "one right way"
@@ -119,5 +118,11 @@ Settle for Result chumpsville or abandon this sugar altogether. Truly, fates wor
119118

120119
# Unresolved questions
121120

122-
None.
121+
`default` and `default_with` are universally reviled as *names*. Need a better name. Some candidates.
122+
123+
* set_default
124+
* or_insert
125+
* insert_default
126+
* insert_if_vacant
127+
* with_default
123128

0 commit comments

Comments
 (0)