Skip to content

Commit

Permalink
doc: Corrected example in 17.8 Deriving implementations for traits
Browse files Browse the repository at this point in the history
Corrected example to to use Rand trait referenced in preceding
description and included an example using the Show trait to print ABC.
  • Loading branch information
iliekturtles committed May 5, 2014
1 parent e65aea5 commit 055cbde
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/doc/tutorial.md
Expand Up @@ -2584,11 +2584,18 @@ for `Eq` and can be used with the equality operators, and that a value
of type `ABC` can be randomly generated and converted to a string:

~~~
extern crate rand;
#[deriving(Eq)]
struct Circle { radius: f64 }
#[deriving(Clone, Show)]
#[deriving(Rand, Show)]
enum ABC { A, B, C }
fn main() {
// Use the Show trait to print "A, B, C."
println!("{}, {}, {}", A, B, C);
}
~~~

The full list of derivable traits is `Eq`, `TotalEq`, `Ord`,
Expand Down

5 comments on commit 055cbde

@bors
Copy link
Contributor

@bors bors commented on 055cbde May 5, 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 iliekturtles@055cbde

@bors
Copy link
Contributor

@bors bors commented on 055cbde May 5, 2014

Choose a reason for hiding this comment

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

merging iliekturtles/rust/tutorial = 055cbde into auto

@bors
Copy link
Contributor

@bors bors commented on 055cbde May 5, 2014

Choose a reason for hiding this comment

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

iliekturtles/rust/tutorial = 055cbde merged ok, testing candidate = d943b0f

@bors
Copy link
Contributor

@bors bors commented on 055cbde May 5, 2014

@bors
Copy link
Contributor

@bors bors commented on 055cbde May 5, 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 = d943b0f

Please sign in to comment.