File tree 1 file changed +9
-7
lines changed
1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -378,23 +378,23 @@ let mut s = String::from("foo");
378
378
let t = String :: from (" bar" );
379
379
380
380
f (|| {
381
- s += t ;
381
+ s += & * t ;
382
382
s
383
383
});
384
384
// Prints "foobar".
385
385
```
386
386
387
387
generates a closure type roughly like the following:
388
388
389
- ``` rust
389
+ ``` rust,ignore
390
390
struct Closure<'a> {
391
- s : String
392
- t : & 'a String
391
+ s : String,
392
+ t : &'a String,
393
393
}
394
394
395
- impl <'a > FnOnce () -> String for Closure <'a > {
395
+ impl<'a> ( FnOnce() -> String) for Closure<'a> {
396
396
fn call_once(self) -> String {
397
- self . s += self . t;
397
+ self.s += &* self.t;
398
398
self.s
399
399
}
400
400
}
@@ -419,12 +419,14 @@ may be necessary to borrow into a local variable in order to capture a single
419
419
field:
420
420
421
421
``` rust
422
+ # use std :: collections :: HashSet ;
423
+ #
422
424
struct SetVec {
423
425
set : HashSet <u32 >,
424
426
vec : Vec <u32 >
425
427
}
426
428
427
- impl Pair {
429
+ impl SetVec {
428
430
fn populate (& mut self ) {
429
431
let vec = & mut self . vec;
430
432
self . set. iter (). for_each (| & n | {
You can’t perform that action at this time.
0 commit comments