@@ -84,7 +84,7 @@ println!("{}", x + z);
84
84
85
85
This gives us an error:
86
86
87
- ``` {notrust, ignore}
87
+ ``` {ignore}
88
88
hello.rs:6:24: 6:25 error: mismatched types: expected `int` but found `&int` (expected int but found &-ptr)
89
89
hello.rs:6 println!("{}", x + z);
90
90
^
@@ -132,7 +132,7 @@ Pointers are useful in languages that are pass-by-value, rather than
132
132
pass-by-reference. Basically, languages can make two choices (this is made
133
133
up syntax, it's not Rust):
134
134
135
- ``` {notrust, ignore}
135
+ ``` {ignore}
136
136
func foo(x) {
137
137
x = 5
138
138
}
@@ -152,7 +152,7 @@ and therefore, can change its value. At the comment, `i` will be `5`.
152
152
So what do pointers have to do with this? Well, since pointers point to a
153
153
location in memory...
154
154
155
- ``` {notrust, ignore}
155
+ ``` {ignore}
156
156
func foo(&int x) {
157
157
*x = 5
158
158
}
@@ -179,7 +179,7 @@ but here are problems with pointers in other languages:
179
179
Uninitialized pointers can cause a problem. For example, what does this program
180
180
do?
181
181
182
- ``` {notrust, ignore}
182
+ ``` {ignore}
183
183
&int x;
184
184
*x = 5; // whoops!
185
185
```
@@ -191,7 +191,7 @@ knows. This might be harmless, and it might be catastrophic.
191
191
When you combine pointers and functions, it's easy to accidentally invalidate
192
192
the memory the pointer is pointing to. For example:
193
193
194
- ``` {notrust, ignore}
194
+ ``` {ignore}
195
195
func make_pointer(): &int {
196
196
x = 5;
197
197
@@ -213,7 +213,7 @@ As one last example of a big problem with pointers, **aliasing** can be an
213
213
issue. Two pointers are said to alias when they point at the same location
214
214
in memory. Like this:
215
215
216
- ``` {notrust, ignore}
216
+ ``` {ignore}
217
217
func mutate(&int i, int j) {
218
218
*i = j;
219
219
}
@@ -398,7 +398,7 @@ fn main() {
398
398
399
399
It gives this error:
400
400
401
- ``` {notrust, ignore}
401
+ ``` {ignore}
402
402
test.rs:5:8: 5:10 error: cannot assign to `*x` because it is borrowed
403
403
test.rs:5 *x -= 1;
404
404
^~
@@ -522,7 +522,7 @@ boxes, though. As a rough approximation, you can treat this Rust code:
522
522
523
523
As being similar to this C code:
524
524
525
- ``` {notrust, ignore}
525
+ ``` {ignore}
526
526
{
527
527
int *x;
528
528
x = (int *)malloc(sizeof(int));
@@ -626,7 +626,7 @@ fn main() {
626
626
627
627
This prints:
628
628
629
- ``` {notrust, ignore}
629
+ ``` {ignore}
630
630
Cons(1, box Cons(2, box Cons(3, box Nil)))
631
631
```
632
632
0 commit comments