From 3bdeb6e7bf0d991734a35cae2fc9963046c32628 Mon Sep 17 00:00:00 2001 From: Baelyk Date: Sat, 17 Mar 2018 15:02:03 -0500 Subject: [PATCH 1/3] Swaps all `_` only parameters for `input` Resolves #442 Changed the parameter to `input`, and uses it in `unimplemented!()` to silence the unused variable warning. Use `{:?}` instead `{}` Meaningful filler for the unimplemented!() macros --- exercises/alphametics/src/lib.rs | 4 ++-- exercises/book-store/src/lib.rs | 4 ++-- exercises/crypto-square/src/lib.rs | 4 ++-- exercises/decimal/src/lib.rs | 4 ++-- exercises/poker/src/lib.rs | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/exercises/alphametics/src/lib.rs b/exercises/alphametics/src/lib.rs index 93a2f3646..1614a0682 100644 --- a/exercises/alphametics/src/lib.rs +++ b/exercises/alphametics/src/lib.rs @@ -1,5 +1,5 @@ use std::collections::HashMap; -pub fn solve(_: &str) -> Option> { - unimplemented!() +pub fn solve(input: &str) -> Option> { + unimplemented!("Solve the alphametric {}", input) } diff --git a/exercises/book-store/src/lib.rs b/exercises/book-store/src/lib.rs index af1e61039..173be8daa 100644 --- a/exercises/book-store/src/lib.rs +++ b/exercises/book-store/src/lib.rs @@ -1,3 +1,3 @@ -pub fn lowest_price(_: &[usize]) -> usize { - unimplemented!() +pub fn lowest_price(input: &[usize]) -> usize { + unimplemented!("Find the lowest price of the bookbasket: {}", input) } diff --git a/exercises/crypto-square/src/lib.rs b/exercises/crypto-square/src/lib.rs index cf84ac82f..e1c7f7459 100644 --- a/exercises/crypto-square/src/lib.rs +++ b/exercises/crypto-square/src/lib.rs @@ -1,3 +1,3 @@ -pub fn encrypt(_: &str) -> String { - unimplemented!() +pub fn encrypt(input: &str) -> String { + unimplemented!("Encrypt {} using a square code", input) } diff --git a/exercises/decimal/src/lib.rs b/exercises/decimal/src/lib.rs index 0c2bddc81..77a491359 100644 --- a/exercises/decimal/src/lib.rs +++ b/exercises/decimal/src/lib.rs @@ -4,7 +4,7 @@ pub struct Decimal { } impl Decimal { - pub fn try_from(_: &str) -> Option { - unimplemented!() + pub fn try_from(input: &str) -> Option { + unimplemented!("Create a new decimal with a value of {}", input) } } diff --git a/exercises/poker/src/lib.rs b/exercises/poker/src/lib.rs index e34909fec..5f83d27cc 100644 --- a/exercises/poker/src/lib.rs +++ b/exercises/poker/src/lib.rs @@ -2,6 +2,6 @@ /// /// Note the type signature: this function should return _the same_ reference to /// the winning hand(s) as were passed in, not reconstructed strings which happen to be equal. -pub fn winning_hands<'a>(_: &[&'a str]) -> Option> { - unimplemented!() +pub fn winning_hands<'a>(input: &[&'a str]) -> Option> { + unimplemented!("Out of {}, which hand wins?", input) } From 4ae7e558814ea02be529dd9e216a13836c1b30e9 Mon Sep 17 00:00:00 2001 From: Baelyk Date: Sat, 17 Mar 2018 18:20:09 -0500 Subject: [PATCH 2/3] Actually used {:?} this time --- exercises/alphametics/src/lib.rs | 2 +- exercises/book-store/src/lib.rs | 2 +- exercises/crypto-square/src/lib.rs | 2 +- exercises/decimal/src/lib.rs | 2 +- exercises/poker/src/lib.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/exercises/alphametics/src/lib.rs b/exercises/alphametics/src/lib.rs index 1614a0682..6f1a8303d 100644 --- a/exercises/alphametics/src/lib.rs +++ b/exercises/alphametics/src/lib.rs @@ -1,5 +1,5 @@ use std::collections::HashMap; pub fn solve(input: &str) -> Option> { - unimplemented!("Solve the alphametric {}", input) + unimplemented!("Solve the alphametric {:?}", input) } diff --git a/exercises/book-store/src/lib.rs b/exercises/book-store/src/lib.rs index 173be8daa..a8fdf839c 100644 --- a/exercises/book-store/src/lib.rs +++ b/exercises/book-store/src/lib.rs @@ -1,3 +1,3 @@ pub fn lowest_price(input: &[usize]) -> usize { - unimplemented!("Find the lowest price of the bookbasket: {}", input) + unimplemented!("Find the lowest price of the bookbasket: {:?}", input) } diff --git a/exercises/crypto-square/src/lib.rs b/exercises/crypto-square/src/lib.rs index e1c7f7459..83de47493 100644 --- a/exercises/crypto-square/src/lib.rs +++ b/exercises/crypto-square/src/lib.rs @@ -1,3 +1,3 @@ pub fn encrypt(input: &str) -> String { - unimplemented!("Encrypt {} using a square code", input) + unimplemented!("Encrypt {:?} using a square code", input) } diff --git a/exercises/decimal/src/lib.rs b/exercises/decimal/src/lib.rs index 77a491359..500e49dd3 100644 --- a/exercises/decimal/src/lib.rs +++ b/exercises/decimal/src/lib.rs @@ -5,6 +5,6 @@ pub struct Decimal { impl Decimal { pub fn try_from(input: &str) -> Option { - unimplemented!("Create a new decimal with a value of {}", input) + unimplemented!("Create a new decimal with a value of {:?}", input) } } diff --git a/exercises/poker/src/lib.rs b/exercises/poker/src/lib.rs index 5f83d27cc..539e04686 100644 --- a/exercises/poker/src/lib.rs +++ b/exercises/poker/src/lib.rs @@ -3,5 +3,5 @@ /// Note the type signature: this function should return _the same_ reference to /// the winning hand(s) as were passed in, not reconstructed strings which happen to be equal. pub fn winning_hands<'a>(input: &[&'a str]) -> Option> { - unimplemented!("Out of {}, which hand wins?", input) + unimplemented!("Out of {:?}, which hand wins?", input) } From 1b6a52aa8d8a78ea065deefaa81c6084812c44d6 Mon Sep 17 00:00:00 2001 From: Baelyk Date: Sat, 17 Mar 2018 18:29:55 -0500 Subject: [PATCH 3/3] Variable names have meaning Stopped using just `input` where something else made more sense. Changed decimal from `{:?}` back to `{}`. --- exercises/alphametics/src/lib.rs | 2 +- exercises/book-store/src/lib.rs | 4 ++-- exercises/decimal/src/lib.rs | 2 +- exercises/poker/src/lib.rs | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/exercises/alphametics/src/lib.rs b/exercises/alphametics/src/lib.rs index 6f1a8303d..5e456202d 100644 --- a/exercises/alphametics/src/lib.rs +++ b/exercises/alphametics/src/lib.rs @@ -1,5 +1,5 @@ use std::collections::HashMap; pub fn solve(input: &str) -> Option> { - unimplemented!("Solve the alphametric {:?}", input) + unimplemented!("Solve the alphametic {:?}", input) } diff --git a/exercises/book-store/src/lib.rs b/exercises/book-store/src/lib.rs index a8fdf839c..306ed9dbe 100644 --- a/exercises/book-store/src/lib.rs +++ b/exercises/book-store/src/lib.rs @@ -1,3 +1,3 @@ -pub fn lowest_price(input: &[usize]) -> usize { - unimplemented!("Find the lowest price of the bookbasket: {:?}", input) +pub fn lowest_price(books: &[usize]) -> usize { + unimplemented!("Find the lowest price of the bookbasket with books {:?}", books) } diff --git a/exercises/decimal/src/lib.rs b/exercises/decimal/src/lib.rs index 500e49dd3..77a491359 100644 --- a/exercises/decimal/src/lib.rs +++ b/exercises/decimal/src/lib.rs @@ -5,6 +5,6 @@ pub struct Decimal { impl Decimal { pub fn try_from(input: &str) -> Option { - unimplemented!("Create a new decimal with a value of {:?}", input) + unimplemented!("Create a new decimal with a value of {}", input) } } diff --git a/exercises/poker/src/lib.rs b/exercises/poker/src/lib.rs index 539e04686..3e91bafea 100644 --- a/exercises/poker/src/lib.rs +++ b/exercises/poker/src/lib.rs @@ -2,6 +2,6 @@ /// /// Note the type signature: this function should return _the same_ reference to /// the winning hand(s) as were passed in, not reconstructed strings which happen to be equal. -pub fn winning_hands<'a>(input: &[&'a str]) -> Option> { - unimplemented!("Out of {:?}, which hand wins?", input) +pub fn winning_hands<'a>(hands: &[&'a str]) -> Option> { + unimplemented!("Out of {:?}, which hand wins?", hands) }