@@ -186,7 +186,7 @@ enum List<T> {
186
186
Nil ,
187
187
Cons (T , ~List <T >),
188
188
}
189
-
189
+
190
190
fn main () {
191
191
let list : List <int > = Cons (1 , ~Cons (2 , ~Cons (3 , ~Nil )));
192
192
println! (" {:?}" , list );
@@ -251,7 +251,7 @@ struct.
251
251
252
252
> ** Note** : the ` @ ` form of managed pointers is deprecated and behind a
253
253
> feature gate (it requires a ` #![feature(managed_pointers)] ` attribute on
254
- > the crate root; remember the semicolon! ). There are replacements, currently
254
+ > the crate root). There are replacements, currently
255
255
> there is ` std::rc::Rc ` and ` std::gc::Gc ` for shared ownership via reference
256
256
> counting and garbage collection respectively.
257
257
@@ -266,7 +266,7 @@ struct Point {
266
266
x: int,
267
267
y: int,
268
268
}
269
-
269
+
270
270
fn main() {
271
271
let a = ~Point { x: 10, y: 20 };
272
272
let b = a;
@@ -297,7 +297,7 @@ struct Point {
297
297
x : int ,
298
298
y : int ,
299
299
}
300
-
300
+
301
301
fn main () {
302
302
let a = @ Point { x : 10 , y : 20 };
303
303
let b = a ;
@@ -361,7 +361,7 @@ So how is this hard? Well, because we're ignoring ownership, the compiler needs
361
361
to take great care to make sure that everything is safe. Despite their complete
362
362
safety, a reference's representation at runtime is the same as that of
363
363
an ordinary pointer in a C program. They introduce zero overhead. The compiler
364
- does all safety checks at compile time.
364
+ does all safety checks at compile time.
365
365
366
366
This theory is called 'region pointers,' and involve a concept called
367
367
'lifetimes'. Here's the simple explanation: would you expect this code to
@@ -477,7 +477,7 @@ fn main() {
477
477
You may think that this gives us terrible performance: return a value and then
478
478
immediately box it up?!?! Isn't that the worst of both worlds? Rust is smarter
479
479
than that. There is no copy in this code. ` main ` allocates enough room for the
480
- ` @int ` , passes a pointer to that memory into ` foo ` as ` x ` , and then ` foo ` writes
480
+ ` @int ` , passes a pointer to that memory into ` foo ` as ` x ` , and then ` foo ` writes
481
481
the value straight into that pointer. This writes the return value directly into
482
482
the allocated box.
483
483
0 commit comments