]> git.lizzy.rs Git - rust.git/commitdiff
doc: Corrected example in 17.8 Deriving implementations for traits
authorMike Boutin <mike.boutin@gmail.com>
Fri, 2 May 2014 17:39:08 +0000 (13:39 -0400)
committerMike Boutin <mike.boutin@gmail.com>
Mon, 5 May 2014 15:25:16 +0000 (11:25 -0400)
Corrected example to to use Rand trait referenced in preceding
description and included an example using the Show trait to print ABC.

src/doc/tutorial.md

index 5378f40238cb2e5058d714bf20c5c90c346c5dbe..a847d47c7b9b1a1d1526e1c12e4b63866c5a669c 100644 (file)
@@ -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`,