@@ -133,6 +133,8 @@ fn main() {
133
133
println!("hello?");
134
134
}
135
135
~~~~
136
+ > *** Note:*** * Macros* are explained in the [ Syntax extensions
137
+ > (3.4)] ( #syntax-extensions ) section.
136
138
137
139
If the Rust compiler was installed successfully, running `rustc
138
140
hello.rs` will produce an executable called ` hello` (or ` hello.exe` on
@@ -1059,7 +1061,7 @@ box, while the owner holds onto a pointer to it:
1059
1061
list -> | Cons | 1 | ~ | -> | Cons | 2 | ~ | -> | Cons | 3 | ~ | -> | Nil |
1060
1062
+--------------+ +--------------+ +--------------+ +--------------+
1061
1063
1062
- > Note: the above diagram shows the logical contents of the enum. The actual
1064
+ > *** Note:*** the above diagram shows the logical contents of the enum. The actual
1063
1065
> memory layout of the enum may vary. For example, for the ` List ` enum shown
1064
1066
> above, Rust guarantees that there will be no enum tag field in the actual
1065
1067
> structure. See the language reference for more details.
@@ -1114,7 +1116,7 @@ let z = x; // no new memory allocated, `x` can no longer be used
1114
1116
~~~~
1115
1117
1116
1118
The ` clone ` method is provided by the ` Clone ` trait, and can be derived for
1117
- our ` List ` type. Traits will be explained in detail later.
1119
+ our ` List ` type. Traits will be explained in detail [ later] ( #traits ) .
1118
1120
1119
1121
~~~ {.ignore}
1120
1122
#[deriving(Clone)]
@@ -1207,8 +1209,8 @@ let ys = Cons(5, ~Cons(10, ~Nil));
1207
1209
assert!(eq(&xs, &ys));
1208
1210
~~~
1209
1211
1210
- Note that Rust doesn't guarantee [ tail-call] ( http://en.wikipedia.org/wiki/Tail_call ) optimization,
1211
- but LLVM is able to handle a simple case like this with optimizations enabled.
1212
+ > *** Note: *** Rust doesn't guarantee [ tail-call] ( http://en.wikipedia.org/wiki/Tail_call ) optimization,
1213
+ > but LLVM is able to handle a simple case like this with optimizations enabled.
1212
1214
1213
1215
## Lists of other types
1214
1216
@@ -1218,6 +1220,9 @@ element type.
1218
1220
1219
1221
The ` u32 ` in the previous definition can be substituted with a type parameter:
1220
1222
1223
+ > *** Note:*** The following code introduces generics, which are explained in a
1224
+ > [ dedicated section] ( #generics ) .
1225
+
1221
1226
~~~
1222
1227
enum List<T> {
1223
1228
Cons(T, ~List<T>),
@@ -1336,9 +1341,13 @@ impl<T: Eq> Eq for List<T> {
1336
1341
1337
1342
let xs = Cons(5, ~Cons(10, ~Nil));
1338
1343
let ys = Cons(5, ~Cons(10, ~Nil));
1344
+ // The methods below are part of the Eq trait,
1345
+ // which we implemented on our linked list.
1339
1346
assert!(xs.eq(&ys));
1340
- assert!(xs == ys);
1341
1347
assert!(!xs.ne(&ys));
1348
+
1349
+ // The Eq trait also allows us to use the shorthand infix operators.
1350
+ assert!(xs == ys);
1342
1351
assert!(!(xs != ys));
1343
1352
~~~
1344
1353
0 commit comments