make exercise more clear
[rust-101.git] / src / part03.rs
index 2a5eb165bcacf0bedcdb6f01ad258bfd4e8f9abd..2085d34463c1cfd715d1489fc883d03032369a8f 100644 (file)
@@ -30,7 +30,7 @@ fn read_vec() -> Vec<i32> {
     //@ concurrently, that also reads from standard input? The result would be a mess. Hence
     //@ Rust requires us to `lock` standard input if we want to perform large operations on
     //@ it. (See [the documentation](https://doc.rust-lang.org/stable/std/io/struct.Stdin.html) for
-    //@ more details.) 
+    //@ more details.)
     for line in stdin.lock().lines() {
         // Rust's type for (dynamic, growable) strings is `String`. However, our variable `line`
         // here is not yet of that type: It has type `io::Result<String>`.
@@ -101,7 +101,8 @@ pub fn main() {
 
 // **Exercise 03.1**: Define a trait `Print` to write a generic version of
 // `SomethingOrNothing::print`.
-// Implement that trait for `i32`, and change the code above to use it.
+// Implement that trait for `i32`, make `print2 use it, and change `main` above to use the new
+// generic `print2` function.
 // I will again provide a skeleton for this solution. It also shows how to attach bounds to generic
 // implementations (just compare it to the `impl` block from the previous exercise).
 // You can read this as "For all types `T` satisfying the `Print` trait, I provide an implementation
@@ -114,6 +115,9 @@ pub fn main() {
 pub trait Print {
     /* Add things here */
 }
+impl Print for i32 {
+    /* Add things here */
+}
 impl<T: Print> SomethingOrNothing<T> {
     fn print2(self) {
         unimplemented!()