File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Expand file tree Collapse file tree 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");
378378let t = String :: from (" bar" );
379379
380380f (|| {
381- s += t ;
381+ s += & * t ;
382382 s
383383});
384384// Prints "foobar".
385385```
386386
387387generates a closure type roughly like the following:
388388
389- ``` rust
389+ ``` rust,ignore
390390struct Closure<'a> {
391- s : String
392- t : & 'a String
391+ s : String,
392+ t : &'a String,
393393}
394394
395- impl <'a > FnOnce () -> String for Closure <'a > {
395+ impl<'a> ( FnOnce() -> String) for Closure<'a> {
396396 fn call_once(self) -> String {
397- self . s += self . t;
397+ self.s += &* self.t;
398398 self.s
399399 }
400400}
@@ -419,12 +419,14 @@ may be necessary to borrow into a local variable in order to capture a single
419419field:
420420
421421``` rust
422+ # use std :: collections :: HashSet ;
423+ #
422424struct SetVec {
423425 set : HashSet <u32 >,
424426 vec : Vec <u32 >
425427}
426428
427- impl Pair {
429+ impl SetVec {
428430 fn populate (& mut self ) {
429431 let vec = & mut self . vec;
430432 self . set. iter (). for_each (| & n | {
You can’t perform that action at this time.
0 commit comments