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
Original file line number Diff line number Diff line change
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

0 comments on commit 055cbde

Please sign in to comment.