Skip to content

Commit 0d978a0

Browse files
authored
Merge pull request #2258 from xfix/patch-3
Add missing Copy bound for K in get_default in RFC 2094
2 parents 1706316 + d2cef34 commit 0d978a0

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

text/2094-nll.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,9 @@ purposes of this section, assume that the `entry` API for maps does
210210
not exist):
211211

212212
```rust
213-
fn get_default<'r,K:Hash+Eq,V:Default>(map: &'r mut HashMap<K,V>,
214-
key: K)
215-
-> &'r mut V {
213+
fn get_default<'r,K:Hash+Eq+Copy,V:Default>(map: &'r mut HashMap<K,V>,
214+
key: K)
215+
-> &'r mut V {
216216
match map.get_mut(&key) { // -------------+ 'r
217217
Some(value) => value, // |
218218
None => { // |
@@ -258,9 +258,9 @@ If we attempt the same workaround for this case that we tried
258258
in the previous example, we will find that it does not work:
259259

260260
```rust
261-
fn get_default1<'r,K:Hash+Eq,V:Default>(map: &'r mut HashMap<K,V>,
262-
key: K)
263-
-> &'r mut V {
261+
fn get_default1<'r,K:Hash+Eq+Copy,V:Default>(map: &'r mut HashMap<K,V>,
262+
key: K)
263+
-> &'r mut V {
264264
match map.get_mut(&key) { // -------------+ 'r
265265
Some(value) => return value, // |
266266
None => { } // |
@@ -281,9 +281,9 @@ the fact that the borrow checker uses the precise control-flow of the
281281
function to determine which borrows are in scope.
282282

283283
```rust
284-
fn get_default2<'r,K:Hash+Eq,V:Default>(map: &'r mut HashMap<K,V>,
285-
key: K)
286-
-> &'r mut V {
284+
fn get_default2<'r,K:Hash+Eq+Copy,V:Default>(map: &'r mut HashMap<K,V>,
285+
key: K)
286+
-> &'r mut V {
287287
if map.contains(&key) {
288288
// ^~~~~~~~~~~~~~~~~~ 'n
289289
return match map.get_mut(&key) { // + 'r

0 commit comments

Comments
 (0)