Skip to content

Commit

Permalink
Be explicit with rustdoc.
Browse files Browse the repository at this point in the history
I missed some annotations, and some were in a different style.
  • Loading branch information
steveklabnik committed Sep 9, 2014
1 parent 6511064 commit c8e5068
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/doc/guide.md
Expand Up @@ -150,7 +150,7 @@ in your file name, use an underscore. `hello_world.rs` versus `goodbye.rs`.

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

```
```{rust}
fn main() {
println!("Hello, world!");
}
Expand All @@ -166,7 +166,7 @@ Hello, world!

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

```
```{rust}
fn main() {
}
Expand All @@ -186,7 +186,7 @@ declaration, with one space in between.

Next up is this line:

```
```{rust}
println!("Hello, world!");
```

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

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

```
```{rust}
let x = 5i;
if x == 5i {
Expand All @@ -574,7 +574,8 @@ if x == 5i {

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

```

```{rust}
let x = 5i;
let y = if x == 5i {
Expand All @@ -586,7 +587,7 @@ let y = if x == 5i {

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

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

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

```rust
```{rust}
struct Point {
x: int,
y: int,
Expand All @@ -1013,7 +1014,7 @@ called a **tuple struct**. Tuple structs do have a name, but their fields
don't:


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

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

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

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

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

Here's how it works:

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

```
```{rust}
struct Circle {
x: f64,
y: f64,
Expand Down

5 comments on commit c8e5068

@bors
Copy link
Contributor

@bors bors commented on c8e5068 Sep 10, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at steveklabnik@c8e5068

@bors
Copy link
Contributor

@bors bors commented on c8e5068 Sep 10, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging steveklabnik/rust/explicitness = c8e5068 into auto

@bors
Copy link
Contributor

@bors bors commented on c8e5068 Sep 10, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

steveklabnik/rust/explicitness = c8e5068 merged ok, testing candidate = 370f8df

@bors
Copy link
Contributor

@bors bors commented on c8e5068 Sep 10, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on c8e5068 Sep 10, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 370f8df

Please sign in to comment.