Skip to content

Commit

Permalink
Rollup merge of rust-lang#30699 - steveklabnik:gh30254, r=apasel422
Browse files Browse the repository at this point in the history
  • Loading branch information
steveklabnik committed Jan 5, 2016
2 parents 2f6b11c + 723ead6 commit d7bf4db
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/doc/book/structs.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,35 @@ fn main() {
}
```

Your structure can still contain `&mut` pointers, which will let
you do some kinds of mutation:

```rust
struct Point {
x: i32,
y: i32,
}

struct PointRef<'a> {
x: &'a mut i32,
y: &'a mut i32,
}

fn main() {
let mut point = Point { x: 0, y: 0 };

{
let r = PointRef { x: &mut point.x, y: &mut point.y };

*r.x = 5;
*r.y = 6;
}

assert_eq!(5, point.x);
assert_eq!(6, point.y);
}
```

# Update syntax

A `struct` can include `..` to indicate that you want to use a copy of some
Expand Down

0 comments on commit d7bf4db

Please sign in to comment.