Skip to content

Commit c8e5068

Browse files
committed
Be explicit with rustdoc.
I missed some annotations, and some were in a different style.
1 parent 6511064 commit c8e5068

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

src/doc/guide.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ in your file name, use an underscore. `hello_world.rs` versus `goodbye.rs`.
150150

151151
Now that you've got your file open, type this in:
152152

153-
```
153+
```{rust}
154154
fn main() {
155155
println!("Hello, world!");
156156
}
@@ -166,7 +166,7 @@ Hello, world!
166166

167167
Success! Let's go over what just happened in detail.
168168

169-
```
169+
```{rust}
170170
fn main() {
171171
172172
}
@@ -186,7 +186,7 @@ declaration, with one space in between.
186186

187187
Next up is this line:
188188

189-
```
189+
```{rust}
190190
println!("Hello, world!");
191191
```
192192

@@ -562,7 +562,7 @@ the block is executed. If it's `false`, then it is not.
562562

563563
If you want something to happen in the `false` case, use an `else`:
564564

565-
```
565+
```{rust}
566566
let x = 5i;
567567
568568
if x == 5i {
@@ -574,7 +574,8 @@ if x == 5i {
574574

575575
This is all pretty standard. However, you can also do this:
576576

577-
```
577+
578+
```{rust}
578579
let x = 5i;
579580
580581
let y = if x == 5i {
@@ -586,7 +587,7 @@ let y = if x == 5i {
586587

587588
Which we can (and probably should) write like this:
588589

589-
```
590+
```{rust}
590591
let x = 5i;
591592
592593
let y = if x == 5i { 10i } else { 15i };
@@ -643,7 +644,7 @@ every line of Rust code you see.
643644
What is this exception that makes us say 'almost?' You saw it already, in this
644645
code:
645646

646-
```
647+
```{rust}
647648
let x = 5i;
648649
649650
let y: int = if x == 5i { 10i } else { 15i };
@@ -989,7 +990,7 @@ notation: `origin.x`.
989990
The values in structs are immutable, like other bindings in Rust. However, you
990991
can use `mut` to make them mutable:
991992

992-
```rust
993+
```{rust}
993994
struct Point {
994995
x: int,
995996
y: int,
@@ -1013,7 +1014,7 @@ called a **tuple struct**. Tuple structs do have a name, but their fields
10131014
don't:
10141015

10151016

1016-
```
1017+
```{rust}
10171018
struct Color(int, int, int);
10181019
struct Point(int, int, int);
10191020
```
@@ -1028,7 +1029,7 @@ let origin = Point(0, 0, 0);
10281029
It is almost always better to use a struct than a tuple struct. We would write
10291030
`Color` and `Point` like this instead:
10301031

1031-
```rust
1032+
```{rust}
10321033
struct Color {
10331034
red: int,
10341035
blue: int,
@@ -1049,7 +1050,7 @@ There _is_ one case when a tuple struct is very useful, though, and that's a
10491050
tuple struct with only one element. We call this a 'newtype,' because it lets
10501051
you create a new type that's a synonym for another one:
10511052

1052-
```
1053+
```{rust}
10531054
struct Inches(int);
10541055
10551056
let length = Inches(10);
@@ -1166,7 +1167,7 @@ what's the solution?
11661167
Rust has a keyword, `match`, that allows you to replace complicated `if`/`else`
11671168
groupings with something more powerful. Check it out:
11681169

1169-
```rust
1170+
```{rust}
11701171
let x = 5i;
11711172
11721173
match x {
@@ -1407,7 +1408,7 @@ We now loop forever with `loop`, and use `break` to break out early.
14071408
`continue` is similar, but instead of ending the loop, goes to the next
14081409
iteration: This will only print the odd numbers:
14091410

1410-
```
1411+
```{rust}
14111412
for x in range(0i, 10i) {
14121413
if x % 2 == 0 { continue; }
14131414
@@ -4122,7 +4123,7 @@ the ability to use this **method call syntax** via the `impl` keyword.
41224123

41234124
Here's how it works:
41244125

4125-
```
4126+
```{rust}
41264127
struct Circle {
41274128
x: f64,
41284129
y: f64,
@@ -4161,7 +4162,7 @@ multiplications later, and we have our area.
41614162
You can also define methods that do not take a `self` parameter. Here's a
41624163
pattern that's very common in Rust code:
41634164

4164-
```
4165+
```{rust}
41654166
struct Circle {
41664167
x: f64,
41674168
y: f64,

0 commit comments

Comments
 (0)