Skip to content

Update guide to reflect changes to enums. #19551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions src/doc/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -1091,9 +1091,9 @@ time. Here's an example:

```{rust}
fn cmp(a: int, b: int) -> Ordering {
if a < b { Less }
else if a > b { Greater }
else { Equal }
if a < b { Ordering::Less }
else if a > b { Ordering::Greater }
else { Ordering::Equal }
}

fn main() {
Expand All @@ -1102,11 +1102,11 @@ fn main() {

let ordering = cmp(x, y);

if ordering == Less {
if ordering == Ordering::Less {
println!("less");
} else if ordering == Greater {
} else if ordering == Ordering::Greater {
println!("greater");
} else if ordering == Equal {
} else if ordering == Ordering::Equal {
println!("equal");
}
}
Expand Down Expand Up @@ -1213,9 +1213,9 @@ section on enums?

```{rust}
fn cmp(a: int, b: int) -> Ordering {
if a < b { Less }
else if a > b { Greater }
else { Equal }
if a < b { Ordering::Less }
else if a > b { Ordering::Greater }
else { Ordering::Equal }
}

fn main() {
Expand All @@ -1224,11 +1224,11 @@ fn main() {

let ordering = cmp(x, y);

if ordering == Less {
if ordering == Ordering::Less {
println!("less");
} else if ordering == Greater {
} else if ordering == Ordering::Greater {
println!("greater");
} else if ordering == Equal {
} else if ordering == Ordering::Equal {
println!("equal");
}
}
Expand All @@ -1238,19 +1238,19 @@ We can re-write this as a `match`:

```{rust}
fn cmp(a: int, b: int) -> Ordering {
if a < b { Less }
else if a > b { Greater }
else { Equal }
if a < b { Ordering::Less }
else if a > b { Ordering::Greater }
else { Ordering::Equal }
}

fn main() {
let x = 5i;
let y = 10i;

match cmp(x, y) {
Less => println!("less"),
Greater => println!("greater"),
Equal => println!("equal"),
Ordering::Less => println!("less"),
Ordering::Greater => println!("greater"),
Ordering::Equal => println!("equal"),
}
}
```
Expand Down Expand Up @@ -1298,19 +1298,19 @@ used. We could also implement the previous line like this:

```{rust}
fn cmp(a: int, b: int) -> Ordering {
if a < b { Less }
else if a > b { Greater }
else { Equal }
if a < b { Ordering::Less }
else if a > b { Ordering::Greater }
else { Ordering::Equal }
}

fn main() {
let x = 5i;
let y = 10i;

println!("{}", match cmp(x, y) {
Less => "less",
Greater => "greater",
Equal => "equal",
Ordering::Less => "less",
Ordering::Greater => "greater",
Ordering::Equal => "equal",
});
}
```
Expand Down