Skip to content

Commit 055cbde

Browse files
committed
doc: Corrected example in 17.8 Deriving implementations for traits
Corrected example to to use Rand trait referenced in preceding description and included an example using the Show trait to print ABC.
1 parent e65aea5 commit 055cbde

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/doc/tutorial.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -2584,11 +2584,18 @@ for `Eq` and can be used with the equality operators, and that a value
25842584
of type `ABC` can be randomly generated and converted to a string:
25852585

25862586
~~~
2587+
extern crate rand;
2588+
25872589
#[deriving(Eq)]
25882590
struct Circle { radius: f64 }
25892591
2590-
#[deriving(Clone, Show)]
2592+
#[deriving(Rand, Show)]
25912593
enum ABC { A, B, C }
2594+
2595+
fn main() {
2596+
// Use the Show trait to print "A, B, C."
2597+
println!("{}, {}, {}", A, B, C);
2598+
}
25922599
~~~
25932600

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

0 commit comments

Comments
 (0)