Skip to content

Commit 82a78c9

Browse files
author
Alexis Hunt
committed
Fix compile errors.
1 parent bdd6d22 commit 82a78c9

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/types.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -378,23 +378,23 @@ let mut s = String::from("foo");
378378
let t = String::from("bar");
379379

380380
f(|| {
381-
s += t;
381+
s += &*t;
382382
s
383383
});
384384
// Prints "foobar".
385385
```
386386

387387
generates a closure type roughly like the following:
388388

389-
```rust
389+
```rust,ignore
390390
struct 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
419419
field:
420420

421421
```rust
422+
# use std::collections::HashSet;
423+
#
422424
struct 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| {

0 commit comments

Comments
 (0)