From 9f33ac4ec929c011d01a70f65a9b80d49cf2f822 Mon Sep 17 00:00:00 2001 From: Peter Goodspeed-Niklaus Date: Sun, 8 Apr 2018 13:32:21 +0200 Subject: [PATCH 1/6] all-your-base: remove #[allow(unused_variables)] --- exercises/all-your-base/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/exercises/all-your-base/src/lib.rs b/exercises/all-your-base/src/lib.rs index 4bfeb357c..5b2ad7d70 100644 --- a/exercises/all-your-base/src/lib.rs +++ b/exercises/all-your-base/src/lib.rs @@ -36,7 +36,6 @@ pub enum Error { /// * Never output leading 0 digits. However, your function must be able to /// process input with leading 0 digits. /// -#[allow(unused_variables)] pub fn convert(number: &[u32], from_base: u32, to_base: u32) -> Result, Error> { - unimplemented!() + unimplemented!("Convert {:?} from base {} to base {}", number, from_base, to_base) } From 72a4826427871aeb00ce311cc159a0ba7671c823 Mon Sep 17 00:00:00 2001 From: Peter Goodspeed-Niklaus Date: Sun, 8 Apr 2018 13:35:21 +0200 Subject: [PATCH 2/6] grade-school: remove #[allow(unused_variables)] --- exercises/grade-school/src/lib.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/exercises/grade-school/src/lib.rs b/exercises/grade-school/src/lib.rs index ffe74b089..5e2cc03bc 100644 --- a/exercises/grade-school/src/lib.rs +++ b/exercises/grade-school/src/lib.rs @@ -1,5 +1,3 @@ -#[allow(unused_variables)] - pub struct School { } @@ -9,7 +7,7 @@ impl School { } pub fn add(&mut self, grade: u32, student: &str) { - unimplemented!() + unimplemented!("Add {} to the roster for {}", student, grade) } pub fn grades(&self) -> Vec { @@ -21,6 +19,6 @@ impl School { // By returning an owned vector instead, // the internal implementation is free to use whatever it chooses. pub fn grade(&self, grade: u32) -> Option> { - unimplemented!() + unimplemented!("Return the list of students in {}", grade) } } From e0f6e03b8fd1f606f094e01d9b24b29a3dd0dd26 Mon Sep 17 00:00:00 2001 From: Peter Goodspeed-Niklaus Date: Sun, 8 Apr 2018 13:37:15 +0200 Subject: [PATCH 3/6] ocr-numbers: remove #[allow(unused_variables)] --- exercises/ocr-numbers/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/exercises/ocr-numbers/src/lib.rs b/exercises/ocr-numbers/src/lib.rs index eb558fb6e..7f7599b6e 100644 --- a/exercises/ocr-numbers/src/lib.rs +++ b/exercises/ocr-numbers/src/lib.rs @@ -7,7 +7,6 @@ pub enum Error { InvalidColumnCount(usize), } -#[allow(unused_variables)] pub fn convert(input: &str) -> Result { - unimplemented!(); + unimplemented!("Convert the input '{}' to a string", input); } From 5b94d07f6f36f69e272884b9326e0e623df6ce9b Mon Sep 17 00:00:00 2001 From: Peter Goodspeed-Niklaus Date: Sun, 8 Apr 2018 14:13:45 +0200 Subject: [PATCH 4/6] react: remove #[allow(unused_variables)] Note that in this case, we couldn't follow the standard procedure of adding the variables to the unimplemented block, because the generic types F and T aren't bounded by Debug. Worse, the closures expected for F possibly _can't_ be bounded by Debug. We use named underscore variables as a fallback. --- exercises/react/src/lib.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/exercises/react/src/lib.rs b/exercises/react/src/lib.rs index 600840ad2..40e442629 100644 --- a/exercises/react/src/lib.rs +++ b/exercises/react/src/lib.rs @@ -1,5 +1,3 @@ -#[allow(unused_variables)] - // Because these are passed without & to some functions, // it will probably be necessary for these two types to be Copy. pub type CellID = (); @@ -20,7 +18,7 @@ pub enum RemoveCallbackError { pub struct Reactor { // Just so that the compiler doesn't complain about an unused type parameter. // You probably want to delete this field. - dummy: T, + dummy: ::std::marker::PhantomData, } // You are guaranteed that Reactor will only be tested against types that are Copy + PartialEq. @@ -30,7 +28,7 @@ impl Reactor { } // Creates an input cell with the specified initial value, returning its ID. - pub fn create_input(&mut self, initial: T) -> CellID { + pub fn create_input(&mut self, _initial: T) -> CellID { unimplemented!() } @@ -47,7 +45,7 @@ impl Reactor { // Notice that there is no way to *remove* a cell. // This means that you may assume, without checking, that if the dependencies exist at creation // time they will continue to exist as long as the Reactor exists. - pub fn create_compute T>(&mut self, dependencies: &[CellID], compute_func: F) -> Result { + pub fn create_compute T>(&mut self, _dependencies: &[CellID], _compute_func: F) -> Result { unimplemented!() } @@ -59,7 +57,7 @@ impl Reactor { // It turns out this introduces a significant amount of extra complexity to this exercise. // We chose not to cover this here, since this exercise is probably enough work as-is. pub fn value(&self, id: CellID) -> Option { - unimplemented!() + unimplemented!("Get the value of the cell whose id is {:?}", id) } // Sets the value of the specified input cell. @@ -73,7 +71,7 @@ impl Reactor { // a `set_value(&mut self, new_value: T)` method on `Cell`. // // As before, that turned out to add too much extra complexity. - pub fn set_value(&mut self, id: CellID, new_value: T) -> Result<(), SetValueError> { + pub fn set_value(&mut self, _id: CellID, _new_value: T) -> Result<(), SetValueError> { unimplemented!() } @@ -89,7 +87,7 @@ impl Reactor { // * Exactly once if the compute cell's value changed as a result of the set_value call. // The value passed to the callback should be the final value of the compute cell after the // set_value call. - pub fn add_callback ()>(&mut self, id: CellID, callback: F) -> Option { + pub fn add_callback ()>(&mut self, _id: CellID, _callback: F) -> Option { unimplemented!() } @@ -99,6 +97,10 @@ impl Reactor { // // A removed callback should no longer be called. pub fn remove_callback(&mut self, cell: CellID, callback: CallbackID) -> Result<(), RemoveCallbackError> { - unimplemented!() + unimplemented!( + "Remove the callback identified by the CallbackID {:?} from the cell {:?}", + callback, + cell, + ) } } From f0052b0cde42ca6aaed36dd0f46c7574d7a462a7 Mon Sep 17 00:00:00 2001 From: Peter Goodspeed-Niklaus Date: Sun, 8 Apr 2018 14:20:37 +0200 Subject: [PATCH 5/6] robot-simulator: remove #[allow(unused_variables)] --- exercises/robot-simulator/src/lib.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/exercises/robot-simulator/src/lib.rs b/exercises/robot-simulator/src/lib.rs index d99a28609..8a3c9eb63 100644 --- a/exercises/robot-simulator/src/lib.rs +++ b/exercises/robot-simulator/src/lib.rs @@ -12,9 +12,12 @@ pub enum Direction { pub struct Robot; impl Robot { - #[allow(unused_variables)] pub fn new(x: isize, y: isize, d: Direction) -> Self { - unimplemented!() + unimplemented!( + "Create a robot at (x, y) ({}, {}) facing {:?}", + x, y, + d, + ) } pub fn turn_right(self) -> Self { @@ -29,9 +32,8 @@ impl Robot { unimplemented!() } - #[allow(unused_variables)] pub fn instructions(self, instructions: &str) -> Self { - unimplemented!() + unimplemented!("Follow the given sequence of instructions: {}", instructions) } pub fn position(&self) -> (isize, isize) { From 15473b905db16db9a2df5dc97b211e97a5b92144 Mon Sep 17 00:00:00 2001 From: Peter Goodspeed-Niklaus Date: Sun, 8 Apr 2018 14:28:03 +0200 Subject: [PATCH 6/6] space-age: remove #[allow(unused_variables)] --- exercises/space-age/src/lib.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/exercises/space-age/src/lib.rs b/exercises/space-age/src/lib.rs index 896bfab2b..9f832e5eb 100644 --- a/exercises/space-age/src/lib.rs +++ b/exercises/space-age/src/lib.rs @@ -1,18 +1,21 @@ // The code below is a stub. Just enough to satisfy the compiler. // In order to pass the tests you can add-to or change any of this code. -#![allow(unused_variables)] +#[derive(Debug)] pub struct Duration; impl From for Duration { fn from(s: u64) -> Self { - unimplemented!() + unimplemented!("s, measured in seconds: {}", s) } } pub trait Planet { fn years_during(d: &Duration) -> f64 { - unimplemented!(); + unimplemented!( + "convert a duration ({:?}) to the number of years on this planet for that duration", + d, + ); } }