@@ -133,6 +133,8 @@ fn main() {
133133 println!("hello?");
134134}
135135~~~~
136+ > *** Note:*** * Macros* are explained in the [ Syntax extensions
137+ > (3.4)] ( #syntax-extensions ) section.
136138
137139If the Rust compiler was installed successfully, running `rustc
138140hello.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:
10591061 list -> | Cons | 1 | ~ | -> | Cons | 2 | ~ | -> | Cons | 3 | ~ | -> | Nil |
10601062 +--------------+ +--------------+ +--------------+ +--------------+
10611063
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
10631065> memory layout of the enum may vary. For example, for the ` List ` enum shown
10641066> above, Rust guarantees that there will be no enum tag field in the actual
10651067> 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
11141116~~~~
11151117
11161118The ` 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 ) .
11181120
11191121~~~ {.ignore}
11201122#[deriving(Clone)]
@@ -1207,8 +1209,8 @@ let ys = Cons(5, ~Cons(10, ~Nil));
12071209assert!(eq(&xs, &ys));
12081210~~~
12091211
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.
12121214
12131215## Lists of other types
12141216
@@ -1218,6 +1220,9 @@ element type.
12181220
12191221The ` u32 ` in the previous definition can be substituted with a type parameter:
12201222
1223+ > *** Note:*** The following code introduces generics, which are explained in a
1224+ > [ dedicated section] ( #generics ) .
1225+
12211226~~~
12221227enum List<T> {
12231228 Cons(T, ~List<T>),
@@ -1336,9 +1341,13 @@ impl<T: Eq> Eq for List<T> {
13361341
13371342let xs = Cons(5, ~Cons(10, ~Nil));
13381343let ys = Cons(5, ~Cons(10, ~Nil));
1344+ // The methods below are part of the Eq trait,
1345+ // which we implemented on our linked list.
13391346assert!(xs.eq(&ys));
1340- assert!(xs == ys);
13411347assert!(!xs.ne(&ys));
1348+
1349+ // The Eq trait also allows us to use the shorthand infix operators.
1350+ assert!(xs == ys);
13421351assert!(!(xs != ys));
13431352~~~
13441353
0 commit comments