Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trpl: small edits to pointers.md examples #21373

Merged
merged 2 commits into from
Jan 23, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/doc/trpl/pointers.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ println!("{}", x + z);
This gives us an error:

```text
hello.rs:6:24: 6:25 error: mismatched types: expected `i32` but found `&i32` (expected i32 but found &-ptr)
hello.rs:6:24: 6:25 error: mismatched types: expected `_`, found `&_` (expected integral variable, found &-ptr)
hello.rs:6 println!("{}", x + z);
^
```
Expand Down Expand Up @@ -305,7 +305,7 @@ References are immutable by default:
let x = 5;
let y = &x;

*y = 5; // error: cannot assign to immutable dereference of `&`-pointer `*y`
*y = 5; // error: cannot assign to immutable borrowed content `*y`
```

They can be made mutable with `mut`, but only if its referent is also mutable.
Expand Down Expand Up @@ -668,7 +668,7 @@ struct BigStruct {
}

fn foo(x: Box<BigStruct>) -> Box<BigStruct> {
return Box::new(*x);
Box::new(*x)
}

fn main() {
Expand Down Expand Up @@ -696,7 +696,7 @@ struct BigStruct {
}

fn foo(x: Box<BigStruct>) -> BigStruct {
return *x;
*x
}

fn main() {
Expand Down