Skip to content

Commit 4347cbb

Browse files
committed
Error message fixes and removed explicit returns in example code
1 parent dcaeb6a commit 4347cbb

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/doc/trpl/pointers.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ println!("{}", x + z);
8787
This gives us an error:
8888

8989
```text
90-
hello.rs:6:24: 6:25 error: mismatched types: expected `i32` but found `&i32` (expected i32 but found &-ptr)
90+
hello.rs:6:24: 6:25 error: mismatched types:
91+
expected `_`,
92+
found `&_`
93+
(expected integral variable,
94+
found &-ptr)
9195
hello.rs:6 println!("{}", x + z);
9296
^
9397
```
@@ -305,7 +309,7 @@ References are immutable by default:
305309
let x = 5;
306310
let y = &x;
307311
308-
*y = 5; // error: cannot assign to immutable dereference of `&`-pointer `*y`
312+
*y = 5; // error: cannot assign to immutable borrowed content `*y`
309313
```
310314

311315
They can be made mutable with `mut`, but only if its referent is also mutable.
@@ -668,7 +672,7 @@ struct BigStruct {
668672
}
669673
670674
fn foo(x: Box<BigStruct>) -> Box<BigStruct> {
671-
return Box::new(*x);
675+
Box::new(*x)
672676
}
673677
674678
fn main() {
@@ -696,7 +700,7 @@ struct BigStruct {
696700
}
697701
698702
fn foo(x: Box<BigStruct>) -> BigStruct {
699-
return *x;
703+
*x
700704
}
701705
702706
fn main() {

0 commit comments

Comments
 (0)