File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -87,7 +87,11 @@ println!("{}", x + z);
87
87
This gives us an error:
88
88
89
89
``` 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)
91
95
hello.rs:6 println!("{}", x + z);
92
96
^
93
97
```
@@ -305,7 +309,7 @@ References are immutable by default:
305
309
let x = 5;
306
310
let y = &x;
307
311
308
- *y = 5; // error: cannot assign to immutable dereference of `&`-pointer `*y`
312
+ *y = 5; // error: cannot assign to immutable borrowed content `*y`
309
313
```
310
314
311
315
They can be made mutable with ` mut ` , but only if its referent is also mutable.
@@ -668,7 +672,7 @@ struct BigStruct {
668
672
}
669
673
670
674
fn foo(x: Box<BigStruct>) -> Box<BigStruct> {
671
- return Box::new(*x);
675
+ Box::new(*x)
672
676
}
673
677
674
678
fn main() {
@@ -696,7 +700,7 @@ struct BigStruct {
696
700
}
697
701
698
702
fn foo(x: Box<BigStruct>) -> BigStruct {
699
- return *x;
703
+ *x
700
704
}
701
705
702
706
fn main() {
You can’t perform that action at this time.
0 commit comments