diff --git a/exercises/accumulate/Cargo.toml b/exercises/accumulate/Cargo.toml index 78fb17a54..1be1f7550 100644 --- a/exercises/accumulate/Cargo.toml +++ b/exercises/accumulate/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "accumulate" version = "0.0.0" diff --git a/exercises/accumulate/tests/accumulate.rs b/exercises/accumulate/tests/accumulate.rs index a5350a5fb..4a74b1db0 100644 --- a/exercises/accumulate/tests/accumulate.rs +++ b/exercises/accumulate/tests/accumulate.rs @@ -59,11 +59,10 @@ fn mutating_closure() { let mut counter = 0; let input = vec![-2, 3, 4, -5]; let expected = vec![2, 3, 4, 5]; - let result = map(input, - |x: i64| { - counter += 1; - x.abs() - }); + let result = map(input, |x: i64| { + counter += 1; + x.abs() + }); assert_eq!(result, expected); assert_eq!(counter, 4); } diff --git a/exercises/acronym/Cargo.toml b/exercises/acronym/Cargo.toml index 3422b3dfb..d476fe177 100644 --- a/exercises/acronym/Cargo.toml +++ b/exercises/acronym/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "acronym" version = "1.0.0" diff --git a/exercises/acronym/tests/acronym.rs b/exercises/acronym/tests/acronym.rs index aaca32d68..6bb0f2a89 100644 --- a/exercises/acronym/tests/acronym.rs +++ b/exercises/acronym/tests/acronym.rs @@ -1,4 +1,4 @@ -extern crate acronym; +use acronym; #[test] fn empty() { diff --git a/exercises/all-your-base/Cargo.toml b/exercises/all-your-base/Cargo.toml index bd2692b2e..10e06c8c9 100644 --- a/exercises/all-your-base/Cargo.toml +++ b/exercises/all-your-base/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "allyourbase" version = "1.0.0" diff --git a/exercises/all-your-base/tests/all-your-base.rs b/exercises/all-your-base/tests/all-your-base.rs index 3f0641a9a..4da0eed57 100644 --- a/exercises/all-your-base/tests/all-your-base.rs +++ b/exercises/all-your-base/tests/all-your-base.rs @@ -1,4 +1,4 @@ -extern crate allyourbase as ayb; +use allyourbase as ayb; #[test] fn single_bit_one_to_decimal() { diff --git a/exercises/allergies/Cargo.toml b/exercises/allergies/Cargo.toml index 2fe84d31b..cef7ea1ab 100644 --- a/exercises/allergies/Cargo.toml +++ b/exercises/allergies/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "allergies" version = "1.1.0" diff --git a/exercises/allergies/tests/allergies.rs b/exercises/allergies/tests/allergies.rs index 1cc830c3c..5bcee4bfc 100644 --- a/exercises/allergies/tests/allergies.rs +++ b/exercises/allergies/tests/allergies.rs @@ -1,5 +1,3 @@ -extern crate allergies; - use allergies::*; fn compare_allergy_vectors(expected: &[Allergen], actual: &[Allergen]) { diff --git a/exercises/alphametics/Cargo-example.toml b/exercises/alphametics/Cargo-example.toml index ef339dd65..508924443 100644 --- a/exercises/alphametics/Cargo-example.toml +++ b/exercises/alphametics/Cargo-example.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "alphametics" version = "0.0.0" diff --git a/exercises/alphametics/Cargo.toml b/exercises/alphametics/Cargo.toml index c5d55d9ea..44deb8348 100644 --- a/exercises/alphametics/Cargo.toml +++ b/exercises/alphametics/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "alphametics" version = "1.3.0" diff --git a/exercises/alphametics/example.rs b/exercises/alphametics/example.rs index a04af36e4..3c4403e92 100644 --- a/exercises/alphametics/example.rs +++ b/exercises/alphametics/example.rs @@ -10,12 +10,20 @@ use std::char; use std::collections::HashMap; use std::collections::HashSet; -fn test_equation(coefficients: &HashMap, cant_be_zero: &HashSet, substitutions: &HashMap) -> bool { +fn test_equation( + coefficients: &HashMap, + cant_be_zero: &HashSet, + substitutions: &HashMap, +) -> bool { if cant_be_zero.iter().any(|d| substitutions[d] == 0) { return false; } - coefficients.iter().map(|(d, &coeff)| i64::from(substitutions[d]) * coeff).sum::() == 0 + coefficients + .iter() + .map(|(d, &coeff)| i64::from(substitutions[d]) * coeff) + .sum::() + == 0 } fn letter_coefficients(puzzle: &str) -> (HashMap, HashSet) { diff --git a/exercises/alphametics/tests/alphametics.rs b/exercises/alphametics/tests/alphametics.rs index 4b52e0e60..e3f45d36e 100644 --- a/exercises/alphametics/tests/alphametics.rs +++ b/exercises/alphametics/tests/alphametics.rs @@ -1,4 +1,4 @@ -extern crate alphametics; +use alphametics; use std::collections::HashMap; fn assert_alphametic_solution_eq(puzzle: &str, solution: &[(char, u8)]) { @@ -29,7 +29,10 @@ fn test_leading_zero_solution_is_invalid() { #[test] #[ignore] fn puzzle_with_two_digits_final_carry() { - assert_alphametic_solution_eq("A + A + A + A + A + A + A + A + A + A + A + B == BCC", &[('A', 9), ('B', 1), ('C', 0)]); + assert_alphametic_solution_eq( + "A + A + A + A + A + A + A + A + A + A + A + B == BCC", + &[('A', 9), ('B', 1), ('C', 0)], + ); } #[test] diff --git a/exercises/anagram/Cargo.toml b/exercises/anagram/Cargo.toml index e31a809e2..ea3013150 100644 --- a/exercises/anagram/Cargo.toml +++ b/exercises/anagram/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "anagram" version = "0.0.0" diff --git a/exercises/anagram/tests/anagram.rs b/exercises/anagram/tests/anagram.rs index cdc318512..464157409 100644 --- a/exercises/anagram/tests/anagram.rs +++ b/exercises/anagram/tests/anagram.rs @@ -1,4 +1,4 @@ -extern crate anagram; +use anagram; use std::collections::HashSet; use std::iter::FromIterator; diff --git a/exercises/armstrong-numbers/Cargo.toml b/exercises/armstrong-numbers/Cargo.toml index f94476a90..c27b4d74d 100644 --- a/exercises/armstrong-numbers/Cargo.toml +++ b/exercises/armstrong-numbers/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "armstrong_numbers" version = "1.0.0" diff --git a/exercises/armstrong-numbers/example.rs b/exercises/armstrong-numbers/example.rs index bf0459296..baa37f282 100644 --- a/exercises/armstrong-numbers/example.rs +++ b/exercises/armstrong-numbers/example.rs @@ -3,5 +3,6 @@ pub fn is_armstrong_number(num: u32) -> bool { let l = s.len(); s.chars() .map(|c| c.to_digit(10).unwrap().pow(l as u32)) - .sum::() == num + .sum::() + == num } diff --git a/exercises/armstrong-numbers/tests/armstrong-numbers.rs b/exercises/armstrong-numbers/tests/armstrong-numbers.rs index fd686d7d4..a785a14ca 100644 --- a/exercises/armstrong-numbers/tests/armstrong-numbers.rs +++ b/exercises/armstrong-numbers/tests/armstrong-numbers.rs @@ -1,4 +1,3 @@ -extern crate armstrong_numbers; use armstrong_numbers::*; #[test] diff --git a/exercises/atbash-cipher/Cargo.toml b/exercises/atbash-cipher/Cargo.toml index ec9f84135..d43249383 100644 --- a/exercises/atbash-cipher/Cargo.toml +++ b/exercises/atbash-cipher/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "atbash-cipher" version = "1.1.0" diff --git a/exercises/atbash-cipher/tests/atbash-cipher.rs b/exercises/atbash-cipher/tests/atbash-cipher.rs index 31f04da74..f53c0daf9 100644 --- a/exercises/atbash-cipher/tests/atbash-cipher.rs +++ b/exercises/atbash-cipher/tests/atbash-cipher.rs @@ -1,4 +1,4 @@ -extern crate atbash_cipher as cipher; +use atbash_cipher as cipher; #[test] fn test_encode_yes() { diff --git a/exercises/beer-song/Cargo.toml b/exercises/beer-song/Cargo.toml index 2618b6cc1..e85b7961d 100644 --- a/exercises/beer-song/Cargo.toml +++ b/exercises/beer-song/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "beer-song" version = "0.0.0" diff --git a/exercises/beer-song/tests/beer-song.rs b/exercises/beer-song/tests/beer-song.rs index 1fddd3700..d5daaf363 100644 --- a/exercises/beer-song/tests/beer-song.rs +++ b/exercises/beer-song/tests/beer-song.rs @@ -1,4 +1,4 @@ -extern crate beer_song as beer; +use beer_song as beer; #[test] fn test_verse_0() { diff --git a/exercises/binary-search/Cargo.toml b/exercises/binary-search/Cargo.toml index fb4e2dc1f..aeab7a084 100644 --- a/exercises/binary-search/Cargo.toml +++ b/exercises/binary-search/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "binary-search" version = "1.3.0" diff --git a/exercises/binary-search/tests/binary-search.rs b/exercises/binary-search/tests/binary-search.rs index f9c2e496e..d6f0bc524 100644 --- a/exercises/binary-search/tests/binary-search.rs +++ b/exercises/binary-search/tests/binary-search.rs @@ -1,5 +1,3 @@ -extern crate binary_search; - use binary_search::find; #[test] diff --git a/exercises/bob/Cargo.toml b/exercises/bob/Cargo.toml index 967acd20b..1483b9ad9 100644 --- a/exercises/bob/Cargo.toml +++ b/exercises/bob/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "bob" version = "1.4.0" diff --git a/exercises/bob/tests/bob.rs b/exercises/bob/tests/bob.rs index 9de4533a3..db45861e8 100644 --- a/exercises/bob/tests/bob.rs +++ b/exercises/bob/tests/bob.rs @@ -1,4 +1,4 @@ -extern crate bob; +use bob; fn process_response_case(phrase: &str, expected_response: &str) { assert_eq!(bob::reply(phrase), expected_response); diff --git a/exercises/book-store/Cargo-example.toml b/exercises/book-store/Cargo-example.toml index 2683bc5f4..5046bd4b7 100644 --- a/exercises/book-store/Cargo-example.toml +++ b/exercises/book-store/Cargo-example.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "book_store" version = "1.3.0" diff --git a/exercises/book-store/Cargo.toml b/exercises/book-store/Cargo.toml index 2683bc5f4..5046bd4b7 100644 --- a/exercises/book-store/Cargo.toml +++ b/exercises/book-store/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "book_store" version = "1.3.0" diff --git a/exercises/book-store/example.rs b/exercises/book-store/example.rs index 228272dfa..2c709f6b0 100644 --- a/exercises/book-store/example.rs +++ b/exercises/book-store/example.rs @@ -25,13 +25,16 @@ impl Group { } fn price(&self) -> Price { - (self.0.borrow().len() as Price) * BOOK_PRICE * match self.0.borrow().len() { - 2 => 95, - 3 => 90, - 4 => 80, - 5 => 75, - _ => 100, - } / 100 + (self.0.borrow().len() as Price) + * BOOK_PRICE + * match self.0.borrow().len() { + 2 => 95, + 3 => 90, + 4 => 80, + 5 => 75, + _ => 100, + } + / 100 } } diff --git a/exercises/book-store/tests/book-store.rs b/exercises/book-store/tests/book-store.rs index b506c7818..8675e6903 100644 --- a/exercises/book-store/tests/book-store.rs +++ b/exercises/book-store/tests/book-store.rs @@ -5,7 +5,6 @@ //! [script]: https://github.com/exercism/rust/blob/master/bin/init_exercise.py //! [canonical-data]: https://raw.githubusercontent.com/exercism/problem-specifications/master/exercises/book-store/canonical_data.json -extern crate book_store; use book_store::*; /// Process a single test case for the property `total` diff --git a/exercises/bowling/Cargo.toml b/exercises/bowling/Cargo.toml index 3ef65f2ad..b14350ea8 100644 --- a/exercises/bowling/Cargo.toml +++ b/exercises/bowling/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "bowling" version = "1.2.0" diff --git a/exercises/bowling/tests/bowling.rs b/exercises/bowling/tests/bowling.rs index fb628d5a7..77a4e876b 100644 --- a/exercises/bowling/tests/bowling.rs +++ b/exercises/bowling/tests/bowling.rs @@ -1,5 +1,3 @@ -extern crate bowling; - use bowling::*; #[test] diff --git a/exercises/bracket-push/Cargo.toml b/exercises/bracket-push/Cargo.toml index 9b156f1f7..73d23780e 100644 --- a/exercises/bracket-push/Cargo.toml +++ b/exercises/bracket-push/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "bracket-push" version = "1.5.0" diff --git a/exercises/bracket-push/example.rs b/exercises/bracket-push/example.rs index 5d2e0f732..44310d294 100644 --- a/exercises/bracket-push/example.rs +++ b/exercises/bracket-push/example.rs @@ -57,7 +57,8 @@ impl From> for MatchingBrackets { impl MatchingBrackets { fn contains(&self, other: &char) -> bool { - let known = self.collection + let known = self + .collection .keys() .chain(self.collection.values()) .collect::>(); diff --git a/exercises/bracket-push/src/lib.rs b/exercises/bracket-push/src/lib.rs index f7004c16f..1241a971a 100644 --- a/exercises/bracket-push/src/lib.rs +++ b/exercises/bracket-push/src/lib.rs @@ -1,3 +1,6 @@ pub fn brackets_are_balanced(string: &str) -> bool { - unimplemented!("Check if the string \"{}\" contains balanced brackets", string); + unimplemented!( + "Check if the string \"{}\" contains balanced brackets", + string + ); } diff --git a/exercises/bracket-push/tests/bracket-push.rs b/exercises/bracket-push/tests/bracket-push.rs index dfd6d211b..c9df5f18a 100644 --- a/exercises/bracket-push/tests/bracket-push.rs +++ b/exercises/bracket-push/tests/bracket-push.rs @@ -1,5 +1,3 @@ -extern crate bracket_push; - use bracket_push::brackets_are_balanced; #[test] diff --git a/exercises/circular-buffer/Cargo.toml b/exercises/circular-buffer/Cargo.toml index b21eefc8c..eb493f4d0 100644 --- a/exercises/circular-buffer/Cargo.toml +++ b/exercises/circular-buffer/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "circular-buffer" version = "1.1.0" diff --git a/exercises/circular-buffer/tests/circular-buffer.rs b/exercises/circular-buffer/tests/circular-buffer.rs index 449806a66..1e73ad865 100644 --- a/exercises/circular-buffer/tests/circular-buffer.rs +++ b/exercises/circular-buffer/tests/circular-buffer.rs @@ -1,4 +1,3 @@ -extern crate circular_buffer; use circular_buffer::{CircularBuffer, Error}; #[test] diff --git a/exercises/clock/Cargo.toml b/exercises/clock/Cargo.toml index 26884e177..376e7f1e5 100644 --- a/exercises/clock/Cargo.toml +++ b/exercises/clock/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "clock" version = "2.4.0" diff --git a/exercises/collatz-conjecture/Cargo.toml b/exercises/collatz-conjecture/Cargo.toml index 5b905f512..e102b3388 100644 --- a/exercises/collatz-conjecture/Cargo.toml +++ b/exercises/collatz-conjecture/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "collatz_conjecture" version = "1.2.1" diff --git a/exercises/collatz-conjecture/tests/collatz-conjecture.rs b/exercises/collatz-conjecture/tests/collatz-conjecture.rs index 86ff0ed2b..f98c5c619 100644 --- a/exercises/collatz-conjecture/tests/collatz-conjecture.rs +++ b/exercises/collatz-conjecture/tests/collatz-conjecture.rs @@ -1,5 +1,3 @@ -extern crate collatz_conjecture; - use collatz_conjecture::*; #[test] diff --git a/exercises/crypto-square/Cargo-example.toml b/exercises/crypto-square/Cargo-example.toml index c2ceff4b7..985096923 100644 --- a/exercises/crypto-square/Cargo-example.toml +++ b/exercises/crypto-square/Cargo-example.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "crypto-square" version = "0.1.0" diff --git a/exercises/crypto-square/Cargo.toml b/exercises/crypto-square/Cargo.toml index 1b96557b6..f19592610 100644 --- a/exercises/crypto-square/Cargo.toml +++ b/exercises/crypto-square/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "crypto-square" version = "0.1.0" diff --git a/exercises/crypto-square/tests/crypto-square.rs b/exercises/crypto-square/tests/crypto-square.rs index 9ad55533d..ba65c2e43 100644 --- a/exercises/crypto-square/tests/crypto-square.rs +++ b/exercises/crypto-square/tests/crypto-square.rs @@ -1,4 +1,3 @@ -extern crate crypto_square; use crypto_square::encrypt; fn test(input: &str, output: &str) { diff --git a/exercises/custom-set/Cargo.toml b/exercises/custom-set/Cargo.toml index 1cc4ef159..2f5fc29bf 100644 --- a/exercises/custom-set/Cargo.toml +++ b/exercises/custom-set/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "custom-set" version = "1.0.1" diff --git a/exercises/custom-set/example.rs b/exercises/custom-set/example.rs index ecab76b68..a3d0c1099 100644 --- a/exercises/custom-set/example.rs +++ b/exercises/custom-set/example.rs @@ -44,26 +44,35 @@ impl CustomSet { } pub fn intersection(&self, other: &Self) -> CustomSet { - CustomSet::new(&self.collection - .iter() - .cloned() - .filter(|c| other.contains(c)) - .collect::>()) + CustomSet::new( + &self + .collection + .iter() + .cloned() + .filter(|c| other.contains(c)) + .collect::>(), + ) } pub fn union(&self, other: &Self) -> CustomSet { - CustomSet::new(&self.collection - .iter() - .cloned() - .chain(other.collection.iter().cloned()) - .collect::>()) + CustomSet::new( + &self + .collection + .iter() + .cloned() + .chain(other.collection.iter().cloned()) + .collect::>(), + ) } pub fn difference(&self, other: &Self) -> CustomSet { - CustomSet::new(&self.collection - .iter() - .cloned() - .filter(|c| !other.contains(c)) - .collect::>()) + CustomSet::new( + &self + .collection + .iter() + .cloned() + .filter(|c| !other.contains(c)) + .collect::>(), + ) } } diff --git a/exercises/decimal/Cargo-example.toml b/exercises/decimal/Cargo-example.toml index 7e7562af4..3423c8071 100644 --- a/exercises/decimal/Cargo-example.toml +++ b/exercises/decimal/Cargo-example.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "decimal" version = "0.1.0" diff --git a/exercises/decimal/Cargo.toml b/exercises/decimal/Cargo.toml index 75189e485..44f62de2d 100644 --- a/exercises/decimal/Cargo.toml +++ b/exercises/decimal/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "decimal" version = "0.1.0" diff --git a/exercises/decimal/example.rs b/exercises/decimal/example.rs index 262c69481..4bae40e7f 100644 --- a/exercises/decimal/example.rs +++ b/exercises/decimal/example.rs @@ -87,7 +87,8 @@ impl Decimal { /// /// This reduces the decimal index, so that the raw values are easier to parse fn reduce(&mut self) { - let extra_zeroes = self.digits + let extra_zeroes = self + .digits .to_string() // produce a decimal representation .chars() .rev() // trailing values diff --git a/exercises/diamond/Cargo.toml b/exercises/diamond/Cargo.toml index b552ed35e..b3df19d05 100644 --- a/exercises/diamond/Cargo.toml +++ b/exercises/diamond/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "diamond" version = "1.1.0" diff --git a/exercises/diamond/tests/diamond.rs b/exercises/diamond/tests/diamond.rs index 74ac9893c..c3d699bdc 100644 --- a/exercises/diamond/tests/diamond.rs +++ b/exercises/diamond/tests/diamond.rs @@ -1,4 +1,4 @@ -extern crate diamond; + use diamond::*; #[test] diff --git a/exercises/difference-of-squares/Cargo.toml b/exercises/difference-of-squares/Cargo.toml index 5e7cda6c7..41e2b29db 100644 --- a/exercises/difference-of-squares/Cargo.toml +++ b/exercises/difference-of-squares/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "difference-of-squares" version = "1.2.0" diff --git a/exercises/difference-of-squares/tests/difference-of-square.rs b/exercises/difference-of-squares/tests/difference-of-square.rs index b6fa4a005..7cc2caa42 100644 --- a/exercises/difference-of-squares/tests/difference-of-square.rs +++ b/exercises/difference-of-squares/tests/difference-of-square.rs @@ -1,4 +1,4 @@ -extern crate difference_of_squares as squares; +use difference_of_squares as squares; #[test] fn test_square_of_sum_1() { diff --git a/exercises/diffie-hellman/Cargo-example.toml b/exercises/diffie-hellman/Cargo-example.toml index 80bd029ea..7fc0123f5 100644 --- a/exercises/diffie-hellman/Cargo-example.toml +++ b/exercises/diffie-hellman/Cargo-example.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "diffie-hellman" version = "0.1.0" diff --git a/exercises/diffie-hellman/Cargo.toml b/exercises/diffie-hellman/Cargo.toml index a6d2b492f..8c1d9df72 100644 --- a/exercises/diffie-hellman/Cargo.toml +++ b/exercises/diffie-hellman/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "diffie-hellman" version = "0.1.0" diff --git a/exercises/diffie-hellman/tests/diffie-hellman.rs b/exercises/diffie-hellman/tests/diffie-hellman.rs index 0f4109df5..f3015998c 100644 --- a/exercises/diffie-hellman/tests/diffie-hellman.rs +++ b/exercises/diffie-hellman/tests/diffie-hellman.rs @@ -1,5 +1,3 @@ -extern crate diffie_hellman; - use diffie_hellman::*; #[test] diff --git a/exercises/dominoes/Cargo.toml b/exercises/dominoes/Cargo.toml index fa56a612b..eed6c1911 100644 --- a/exercises/dominoes/Cargo.toml +++ b/exercises/dominoes/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "dominoes" version = "2.1.0" diff --git a/exercises/dominoes/example.rs b/exercises/dominoes/example.rs index 34e5aef67..72de2d4f3 100644 --- a/exercises/dominoes/example.rs +++ b/exercises/dominoes/example.rs @@ -70,11 +70,13 @@ impl AvailabilityTable { pub fn chain(dominoes: &[Domino]) -> Option> { match dominoes.len() { 0 => Some(vec![]), - 1 => if dominoes[0].0 == dominoes[0].1 { - Some(vec![dominoes[0]]) - } else { - None - }, + 1 => { + if dominoes[0].0 == dominoes[0].1 { + Some(vec![dominoes[0]]) + } else { + None + } + } _ => { // First check if the total number of each amount of dots is even, if not it's not // possible to complete a cycle. This follows from that it's an Eulerian path. diff --git a/exercises/dominoes/tests/dominoes.rs b/exercises/dominoes/tests/dominoes.rs index f6d0c8d9d..fa882078c 100644 --- a/exercises/dominoes/tests/dominoes.rs +++ b/exercises/dominoes/tests/dominoes.rs @@ -1,6 +1,6 @@ -extern crate dominoes; +use dominoes; -use CheckResult::*; +use crate::CheckResult::*; type Domino = (u8, u8); @@ -33,7 +33,10 @@ fn check(input: &[Domino]) -> CheckResult { return Correct; } - let mut output_sorted = output.iter().map(|&d| normalize(d)).collect::>(); + let mut output_sorted = output + .iter() + .map(|&d| normalize(d)) + .collect::>(); output_sorted.sort(); let mut input_sorted = input.iter().map(|&d| normalize(d)).collect::>(); input_sorted.sort(); diff --git a/exercises/dot-dsl/Cargo.toml b/exercises/dot-dsl/Cargo.toml index 57a458b0a..3da0d6721 100644 --- a/exercises/dot-dsl/Cargo.toml +++ b/exercises/dot-dsl/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "dot-dsl" version = "0.1.0" diff --git a/exercises/dot-dsl/tests/dot-dsl.rs b/exercises/dot-dsl/tests/dot-dsl.rs index cce5a389d..0f15d7150 100644 --- a/exercises/dot-dsl/tests/dot-dsl.rs +++ b/exercises/dot-dsl/tests/dot-dsl.rs @@ -2,9 +2,9 @@ extern crate maplit; extern crate dot_dsl; -use dot_dsl::graph::Graph; use dot_dsl::graph::graph_items::edge::Edge; use dot_dsl::graph::graph_items::node::Node; +use dot_dsl::graph::Graph; #[test] fn test_empty_graph() { @@ -67,7 +67,7 @@ fn test_graph_with_one_edge() { fn test_graph_with_one_attribute() { let graph = Graph::new().with_attrs(&[("foo", "1")]); - let expected_attrs = hashmap!{ + let expected_attrs = hashmap! { "foo".to_string() => "1".to_string(), }; @@ -129,11 +129,13 @@ fn test_graph_with_attributes() { #[ignore] fn test_graph_stores_attributes() { let attributes = [("foo", "bar"), ("bat", "baz"), ("bim", "bef")]; - let graph = Graph::new().with_nodes(&['a', 'b', 'c'] - .iter() - .enumerate() - .map(|(i, n)| Node::new(&n.to_string()).with_attrs(&attributes[i..i + 1])) - .collect::>()); + let graph = Graph::new().with_nodes( + &['a', 'b', 'c'] + .iter() + .enumerate() + .map(|(i, n)| Node::new(&n.to_string()).with_attrs(&attributes[i..i + 1])) + .collect::>(), + ); assert_eq!( graph diff --git a/exercises/etl/Cargo.toml b/exercises/etl/Cargo.toml index ce735e012..e94ff4da1 100644 --- a/exercises/etl/Cargo.toml +++ b/exercises/etl/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "etl" version = "1.0.0" diff --git a/exercises/etl/tests/etl.rs b/exercises/etl/tests/etl.rs index 67d1527de..ff28dcfb1 100644 --- a/exercises/etl/tests/etl.rs +++ b/exercises/etl/tests/etl.rs @@ -1,4 +1,4 @@ -extern crate etl; +use etl; use std::collections::BTreeMap; diff --git a/exercises/forth/Cargo.toml b/exercises/forth/Cargo.toml index a56ae8974..912e8e5c0 100644 --- a/exercises/forth/Cargo.toml +++ b/exercises/forth/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "forth" version = "1.7.0" diff --git a/exercises/forth/example.rs b/exercises/forth/example.rs index b32e57aa9..9a14b518e 100644 --- a/exercises/forth/example.rs +++ b/exercises/forth/example.rs @@ -40,8 +40,9 @@ impl FromStr for Term { ":" => Ok(Term::StartDefinition), ";" => Ok(Term::EndDefinition), _ => Err(()), - }.or_else(|_| Value::from_str(s).map(Term::Number)) - .or_else(|_| Ok(Term::Word(s.to_ascii_lowercase()))) + } + .or_else(|_| Value::from_str(s).map(Term::Number)) + .or_else(|_| Ok(Term::Word(s.to_ascii_lowercase()))) } } @@ -98,9 +99,11 @@ impl Forth { "/" => self.bin_op(|(a, b)| a.checked_div(b).ok_or(Error::DivisionByZero)), "dup" => self.pop().and_then(|a| self.push(a).and(self.push(a))), "drop" => self.pop().and(Forth::ok()), - "swap" => self.pop_two() + "swap" => self + .pop_two() .and_then(|(a, b)| self.push(b).and(self.push(a))), - "over" => self.pop_two() + "over" => self + .pop_two() .and_then(|(a, b)| self.push(a).and(self.push(b)).and(self.push(a))), _ => Err(Error::UnknownWord), } @@ -151,11 +154,13 @@ impl Forth { for t in code.iter() { match t { Term::Number(_) => resolved_def.push_back(t.clone()), - Term::Word(s) => if let Some(cs) = self.defs.get(s) { - resolved_def.append(&mut cs.clone()); - } else { - resolved_def.push_back(t.clone()); - }, + Term::Word(s) => { + if let Some(cs) = self.defs.get(s) { + resolved_def.append(&mut cs.clone()); + } else { + resolved_def.push_back(t.clone()); + } + } _ => unimplemented!("not even sure a definition in a definition is valid Forth"), } } diff --git a/exercises/forth/tests/forth.rs b/exercises/forth/tests/forth.rs index 8f91533fb..dcf99aae6 100644 --- a/exercises/forth/tests/forth.rs +++ b/exercises/forth/tests/forth.rs @@ -1,5 +1,3 @@ -extern crate forth; - use forth::{Error, Forth, Value}; #[test] diff --git a/exercises/gigasecond/Cargo.toml b/exercises/gigasecond/Cargo.toml index 42eb3fb3c..857600c8b 100644 --- a/exercises/gigasecond/Cargo.toml +++ b/exercises/gigasecond/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "gigasecond" version = "1.1.0" diff --git a/exercises/gigasecond/src/lib.rs b/exercises/gigasecond/src/lib.rs index fc2f2c180..8b5673093 100644 --- a/exercises/gigasecond/src/lib.rs +++ b/exercises/gigasecond/src/lib.rs @@ -1,4 +1,3 @@ -extern crate chrono; use chrono::{DateTime, Utc}; // Returns a Utc DateTime one billion seconds after start. diff --git a/exercises/gigasecond/tests/gigasecond.rs b/exercises/gigasecond/tests/gigasecond.rs index 266ad8358..b42c35a06 100644 --- a/exercises/gigasecond/tests/gigasecond.rs +++ b/exercises/gigasecond/tests/gigasecond.rs @@ -1,5 +1,5 @@ -extern crate gigasecond; -extern crate chrono; +use gigasecond; + use chrono::{TimeZone, Utc}; #[test] diff --git a/exercises/grade-school/Cargo.toml b/exercises/grade-school/Cargo.toml index 31a2b1a9f..43ad34405 100644 --- a/exercises/grade-school/Cargo.toml +++ b/exercises/grade-school/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "grade-school" version = "0.0.0" diff --git a/exercises/grade-school/tests/grade-school.rs b/exercises/grade-school/tests/grade-school.rs index bb27b8259..65146e15d 100644 --- a/exercises/grade-school/tests/grade-school.rs +++ b/exercises/grade-school/tests/grade-school.rs @@ -1,4 +1,4 @@ -extern crate grade_school as school; +use grade_school as school; fn some_strings(v: &[&str]) -> Option> { Some(v.iter().map(|s| s.to_string()).collect()) diff --git a/exercises/grains/Cargo.toml b/exercises/grains/Cargo.toml index 3fa534346..6bf141e72 100644 --- a/exercises/grains/Cargo.toml +++ b/exercises/grains/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "grains" version = "1.2.0" diff --git a/exercises/grains/tests/grains.rs b/exercises/grains/tests/grains.rs index 61a9c603a..25c990dd9 100644 --- a/exercises/grains/tests/grains.rs +++ b/exercises/grains/tests/grains.rs @@ -1,4 +1,4 @@ -extern crate grains; +use grains; #[test] fn square_one() { diff --git a/exercises/grep/Cargo.toml b/exercises/grep/Cargo.toml index 4bfad5589..ee945edf7 100644 --- a/exercises/grep/Cargo.toml +++ b/exercises/grep/Cargo.toml @@ -2,5 +2,6 @@ failure = "0.1.1" [package] +edition = "2018" name = "grep" version = "1.2.0" diff --git a/exercises/grep/src/lib.rs b/exercises/grep/src/lib.rs index f0b8f02da..20e7a2af8 100644 --- a/exercises/grep/src/lib.rs +++ b/exercises/grep/src/lib.rs @@ -1,5 +1,3 @@ -extern crate failure; - use failure::Error; /// While using raw slice of str to handle flags is convenient, diff --git a/exercises/grep/tests/grep.rs b/exercises/grep/tests/grep.rs index 0476d0351..a5485b076 100644 --- a/exercises/grep/tests/grep.rs +++ b/exercises/grep/tests/grep.rs @@ -1,5 +1,3 @@ -extern crate grep; - use grep::{grep, Flags}; use std::fs; @@ -72,7 +70,8 @@ impl<'a> Fixture<'a> { } else { (file_name, IN_THE_WHITE_NIGHT_CONTENT) } - }).collect::>(); + }) + .collect::>(); set_up_files(&file_name_content_pairs); } diff --git a/exercises/hamming/Cargo.toml b/exercises/hamming/Cargo.toml index e8c13af23..efb643e20 100644 --- a/exercises/hamming/Cargo.toml +++ b/exercises/hamming/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "hamming" version = "2.1.1" diff --git a/exercises/hamming/tests/hamming.rs b/exercises/hamming/tests/hamming.rs index 523e40160..24e2637e3 100644 --- a/exercises/hamming/tests/hamming.rs +++ b/exercises/hamming/tests/hamming.rs @@ -1,4 +1,4 @@ -extern crate hamming; +use hamming; fn process_distance_case(strand_pair: [&str; 2], expected_distance: Option) { assert_eq!( diff --git a/exercises/hello-world/Cargo.toml b/exercises/hello-world/Cargo.toml index 69311b8f5..4d9f8bb06 100644 --- a/exercises/hello-world/Cargo.toml +++ b/exercises/hello-world/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "hello-world" version = "1.1.0" diff --git a/exercises/hello-world/tests/hello-world.rs b/exercises/hello-world/tests/hello-world.rs index 99a3c1561..c0d9536db 100644 --- a/exercises/hello-world/tests/hello-world.rs +++ b/exercises/hello-world/tests/hello-world.rs @@ -1,4 +1,4 @@ -extern crate hello_world; +use hello_world; #[test] fn test_hello_world() { diff --git a/exercises/hexadecimal/Cargo.toml b/exercises/hexadecimal/Cargo.toml index 313084bc0..062e6a9a0 100644 --- a/exercises/hexadecimal/Cargo.toml +++ b/exercises/hexadecimal/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "hexadecimal" version = "0.0.0" diff --git a/exercises/isbn-verifier/Cargo.toml b/exercises/isbn-verifier/Cargo.toml index 2fa438447..01a1e82af 100644 --- a/exercises/isbn-verifier/Cargo.toml +++ b/exercises/isbn-verifier/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "isbn-verifier" version = "2.7.0" diff --git a/exercises/isbn-verifier/tests/isbn-verifier.rs b/exercises/isbn-verifier/tests/isbn-verifier.rs index 930f8dd02..ea381c0b9 100644 --- a/exercises/isbn-verifier/tests/isbn-verifier.rs +++ b/exercises/isbn-verifier/tests/isbn-verifier.rs @@ -1,5 +1,3 @@ -extern crate isbn_verifier; - use isbn_verifier::is_valid_isbn; #[test] diff --git a/exercises/isogram/Cargo.toml b/exercises/isogram/Cargo.toml index 63f479d41..9841e7595 100644 --- a/exercises/isogram/Cargo.toml +++ b/exercises/isogram/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "isogram" version = "1.3.0" diff --git a/exercises/isogram/example.rs b/exercises/isogram/example.rs index 2a32046d2..c475e7a3e 100644 --- a/exercises/isogram/example.rs +++ b/exercises/isogram/example.rs @@ -1,12 +1,13 @@ pub fn check(word: &str) -> bool { // Filter all non-Alphabetic character out and collect them in a new String - let normalized_string: String = word.to_lowercase() + let normalized_string: String = word + .to_lowercase() .chars() .filter(|c| c.is_alphabetic()) .collect(); /* Find the char element from back and front and compare the index. - If it is the same unique char the index will be the same.*/ + If it is the same unique char the index will be the same.*/ let is_unique = |x: char, word: &str| word.find(x).unwrap() == word.rfind(x).unwrap(); // Length should be the same if it is a isogram diff --git a/exercises/isogram/tests/isogram.rs b/exercises/isogram/tests/isogram.rs index c94d44922..932bd3cd4 100644 --- a/exercises/isogram/tests/isogram.rs +++ b/exercises/isogram/tests/isogram.rs @@ -1,5 +1,3 @@ -extern crate isogram; - use isogram::check; #[test] diff --git a/exercises/largest-series-product/Cargo.toml b/exercises/largest-series-product/Cargo.toml index 37fd83a73..f03ff47ec 100644 --- a/exercises/largest-series-product/Cargo.toml +++ b/exercises/largest-series-product/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "largest-series-product" version = "1.2.0" diff --git a/exercises/largest-series-product/tests/largest-series-product.rs b/exercises/largest-series-product/tests/largest-series-product.rs index 92781dc50..97ca0a6a9 100644 --- a/exercises/largest-series-product/tests/largest-series-product.rs +++ b/exercises/largest-series-product/tests/largest-series-product.rs @@ -1,5 +1,3 @@ -extern crate largest_series_product; - use largest_series_product::*; #[test] diff --git a/exercises/leap/Cargo.toml b/exercises/leap/Cargo.toml index d96dc5de6..2e0adb3ed 100644 --- a/exercises/leap/Cargo.toml +++ b/exercises/leap/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "leap" version = "1.4.0" diff --git a/exercises/leap/tests/leap.rs b/exercises/leap/tests/leap.rs index 097dd96e5..1198a9938 100644 --- a/exercises/leap/tests/leap.rs +++ b/exercises/leap/tests/leap.rs @@ -1,4 +1,4 @@ -extern crate leap; +use leap; fn process_leapyear_case(year: u64, expected: bool) { assert_eq!(leap::is_leap_year(year), expected); diff --git a/exercises/luhn-from/Cargo.toml b/exercises/luhn-from/Cargo.toml index 8fdafb024..5e0bc0a83 100644 --- a/exercises/luhn-from/Cargo.toml +++ b/exercises/luhn-from/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "luhn-from" version = "0.0.0" diff --git a/exercises/luhn-from/example.rs b/exercises/luhn-from/example.rs index 77bea10d5..1cfd286a7 100644 --- a/exercises/luhn-from/example.rs +++ b/exercises/luhn-from/example.rs @@ -15,7 +15,9 @@ impl Luhn { .enumerate() .map(|(index, digit)| if index % 2 == 0 { digit } else { digit * 2 }) .map(|digit| if digit > 9 { digit - 9 } else { digit }) - .sum::() % 10 == 0 + .sum::() + % 10 + == 0 } } diff --git a/exercises/luhn-trait/Cargo.toml b/exercises/luhn-trait/Cargo.toml index e0bd9df67..c68f2e3f0 100644 --- a/exercises/luhn-trait/Cargo.toml +++ b/exercises/luhn-trait/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "luhn-trait" version = "0.0.0" diff --git a/exercises/luhn-trait/example.rs b/exercises/luhn-trait/example.rs index b703231ff..ed71406fd 100644 --- a/exercises/luhn-trait/example.rs +++ b/exercises/luhn-trait/example.rs @@ -14,7 +14,9 @@ impl Luhn for String { .enumerate() .map(|(index, digit)| if index % 2 == 0 { digit } else { digit * 2 }) .map(|digit| if digit > 9 { digit - 9 } else { digit }) - .sum::() % 10 == 0 + .sum::() + % 10 + == 0 } } diff --git a/exercises/luhn/Cargo.toml b/exercises/luhn/Cargo.toml index 75c0ccb51..af784656b 100644 --- a/exercises/luhn/Cargo.toml +++ b/exercises/luhn/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "luhn" version = "1.3.0" diff --git a/exercises/luhn/example.rs b/exercises/luhn/example.rs index ce52adf61..4308887d6 100644 --- a/exercises/luhn/example.rs +++ b/exercises/luhn/example.rs @@ -12,5 +12,7 @@ pub fn is_valid(candidate: &str) -> bool { .enumerate() .map(|(index, digit)| if index % 2 == 0 { digit } else { digit * 2 }) .map(|digit| if digit > 9 { digit - 9 } else { digit }) - .sum::() % 10 == 0 + .sum::() + % 10 + == 0 } diff --git a/exercises/luhn/tests/luhn.rs b/exercises/luhn/tests/luhn.rs index 061b9c90a..0915cdf73 100644 --- a/exercises/luhn/tests/luhn.rs +++ b/exercises/luhn/tests/luhn.rs @@ -1,5 +1,3 @@ -extern crate luhn; - use luhn::*; #[test] diff --git a/exercises/macros/Cargo.toml b/exercises/macros/Cargo.toml index 8e58411d0..b7d10d7b2 100644 --- a/exercises/macros/Cargo.toml +++ b/exercises/macros/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "macros" version = "0.1.0" diff --git a/exercises/minesweeper/Cargo.toml b/exercises/minesweeper/Cargo.toml index fe1f5c79a..acb6b8e6f 100644 --- a/exercises/minesweeper/Cargo.toml +++ b/exercises/minesweeper/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "minesweeper" version = "1.1.0" diff --git a/exercises/minesweeper/tests/minesweeper.rs b/exercises/minesweeper/tests/minesweeper.rs index 09fc121a2..632911263 100644 --- a/exercises/minesweeper/tests/minesweeper.rs +++ b/exercises/minesweeper/tests/minesweeper.rs @@ -1,4 +1,4 @@ -extern crate minesweeper; + use minesweeper::annotate; diff --git a/exercises/nth-prime/Cargo.toml b/exercises/nth-prime/Cargo.toml index bd0526ded..fc1c776d6 100644 --- a/exercises/nth-prime/Cargo.toml +++ b/exercises/nth-prime/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "nth_prime" version = "2.1.0" diff --git a/exercises/nth-prime/tests/nth-prime.rs b/exercises/nth-prime/tests/nth-prime.rs index 69c92f9da..db2af9c0b 100644 --- a/exercises/nth-prime/tests/nth-prime.rs +++ b/exercises/nth-prime/tests/nth-prime.rs @@ -1,4 +1,4 @@ -extern crate nth_prime as np; +use nth_prime as np; #[test] fn test_first_prime() { diff --git a/exercises/nucleotide-codons/Cargo.toml b/exercises/nucleotide-codons/Cargo.toml index ff77d8534..1619ea0cf 100644 --- a/exercises/nucleotide-codons/Cargo.toml +++ b/exercises/nucleotide-codons/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "nucleotide_codons" version = "0.1.0" diff --git a/exercises/nucleotide-codons/tests/codons.rs b/exercises/nucleotide-codons/tests/codons.rs index acd310f1c..2c784ce55 100644 --- a/exercises/nucleotide-codons/tests/codons.rs +++ b/exercises/nucleotide-codons/tests/codons.rs @@ -1,4 +1,4 @@ -extern crate nucleotide_codons as codons; +use nucleotide_codons as codons; #[test] fn test_methionine() { diff --git a/exercises/nucleotide-count/Cargo.toml b/exercises/nucleotide-count/Cargo.toml index ae5eceadb..894c579d1 100644 --- a/exercises/nucleotide-count/Cargo.toml +++ b/exercises/nucleotide-count/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "nucleotide-count" version = "1.3.0" diff --git a/exercises/nucleotide-count/tests/nucleotide-count.rs b/exercises/nucleotide-count/tests/nucleotide-count.rs index 403ae9c53..e910798ad 100644 --- a/exercises/nucleotide-count/tests/nucleotide-count.rs +++ b/exercises/nucleotide-count/tests/nucleotide-count.rs @@ -1,4 +1,4 @@ -extern crate nucleotide_count as dna; +use nucleotide_count as dna; use std::collections::HashMap; diff --git a/exercises/ocr-numbers/Cargo.toml b/exercises/ocr-numbers/Cargo.toml index 7cc7fa0be..848a2a884 100644 --- a/exercises/ocr-numbers/Cargo.toml +++ b/exercises/ocr-numbers/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "ocr-numbers" version = "0.0.0" diff --git a/exercises/ocr-numbers/example.rs b/exercises/ocr-numbers/example.rs index 261e9e177..98153936f 100644 --- a/exercises/ocr-numbers/example.rs +++ b/exercises/ocr-numbers/example.rs @@ -29,7 +29,9 @@ pub fn convert(input: &str) -> Result { let line_chars = line.chars().collect::>(); for (char_number, char_chunk) in line_chars.chunks(3).enumerate() { - let char_chars = unparsed_characters.entry(char_number).or_insert_with(Vec::new); + let char_chars = unparsed_characters + .entry(char_number) + .or_insert_with(Vec::new); for c in char_chunk { char_chars.push(*c); } diff --git a/exercises/ocr-numbers/tests/ocr-numbers.rs b/exercises/ocr-numbers/tests/ocr-numbers.rs index 5e148473f..535165c39 100644 --- a/exercises/ocr-numbers/tests/ocr-numbers.rs +++ b/exercises/ocr-numbers/tests/ocr-numbers.rs @@ -1,4 +1,4 @@ -extern crate ocr_numbers as ocr; +use ocr_numbers as ocr; #[test] #[cfg_attr(rustfmt, rustfmt_skip)] diff --git a/exercises/paasio/Cargo.toml b/exercises/paasio/Cargo.toml index 7f4fda53f..83a8e7309 100644 --- a/exercises/paasio/Cargo.toml +++ b/exercises/paasio/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "paasio" version = "0.0.0" diff --git a/exercises/paasio/tests/paasio.rs b/exercises/paasio/tests/paasio.rs index 908cd9457..f9a65c925 100644 --- a/exercises/paasio/tests/paasio.rs +++ b/exercises/paasio/tests/paasio.rs @@ -1,4 +1,4 @@ -extern crate paasio; +use paasio; /// test a few read scenarios macro_rules! test_read { @@ -176,9 +176,7 @@ read_byte_literal( )); test_write!(#[ignore] write_byte_literal( - &[ - 2_u8, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, - ][..], + &[2_u8, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61,][..], |d: &[u8]| d.len() )); diff --git a/exercises/palindrome-products/Cargo.toml b/exercises/palindrome-products/Cargo.toml index 29632100d..1d13774df 100644 --- a/exercises/palindrome-products/Cargo.toml +++ b/exercises/palindrome-products/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "palindrome-products" version = "1.1.0" diff --git a/exercises/palindrome-products/tests/palindrome-products.rs b/exercises/palindrome-products/tests/palindrome-products.rs index 87975aef9..0a7cc4318 100644 --- a/exercises/palindrome-products/tests/palindrome-products.rs +++ b/exercises/palindrome-products/tests/palindrome-products.rs @@ -1,4 +1,3 @@ -extern crate palindrome_products; use palindrome_products::*; #[test] diff --git a/exercises/pangram/Cargo.toml b/exercises/pangram/Cargo.toml index 541dca162..a592580f1 100644 --- a/exercises/pangram/Cargo.toml +++ b/exercises/pangram/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "pangram" version = "0.0.0" diff --git a/exercises/pangram/example.rs b/exercises/pangram/example.rs index b0fd0d433..f2870ea27 100644 --- a/exercises/pangram/example.rs +++ b/exercises/pangram/example.rs @@ -7,7 +7,8 @@ pub fn is_pangram(sentence: &str) -> bool { .chars() .filter(|c| c.is_alphabetic()) .filter(|c| c.is_ascii()) - .collect::>() == english_letter_set() + .collect::>() + == english_letter_set() } fn english_letter_set() -> BTreeSet { diff --git a/exercises/pangram/tests/pangram.rs b/exercises/pangram/tests/pangram.rs index 2c3d70ac3..8db231d2e 100644 --- a/exercises/pangram/tests/pangram.rs +++ b/exercises/pangram/tests/pangram.rs @@ -1,5 +1,3 @@ -extern crate pangram; - use pangram::*; #[test] diff --git a/exercises/parallel-letter-frequency/Cargo.toml b/exercises/parallel-letter-frequency/Cargo.toml index 7a2b949e0..898f4f876 100644 --- a/exercises/parallel-letter-frequency/Cargo.toml +++ b/exercises/parallel-letter-frequency/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "parallel-letter-frequency" version = "0.0.0" diff --git a/exercises/parallel-letter-frequency/tests/parallel-letter-frequency.rs b/exercises/parallel-letter-frequency/tests/parallel-letter-frequency.rs index 7cf26fa86..51165c335 100644 --- a/exercises/parallel-letter-frequency/tests/parallel-letter-frequency.rs +++ b/exercises/parallel-letter-frequency/tests/parallel-letter-frequency.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -extern crate parallel_letter_frequency as frequency; +use parallel_letter_frequency as frequency; // Poem by Friedrich Schiller. The corresponding music is the European Anthem. const ODE_AN_DIE_FREUDE: [&'static str; 8] = [ diff --git a/exercises/pascals-triangle/Cargo.toml b/exercises/pascals-triangle/Cargo.toml index 9c8581f05..d308b66e4 100644 --- a/exercises/pascals-triangle/Cargo.toml +++ b/exercises/pascals-triangle/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "pascals-triangle" version = "1.5.0" diff --git a/exercises/pascals-triangle/example.rs b/exercises/pascals-triangle/example.rs index e712369fb..63f70a62d 100644 --- a/exercises/pascals-triangle/example.rs +++ b/exercises/pascals-triangle/example.rs @@ -4,15 +4,11 @@ pub struct PascalsTriangle { impl PascalsTriangle { pub fn new(row_count: u32) -> Self { - PascalsTriangle { - row_count, - } + PascalsTriangle { row_count } } pub fn rows(&self) -> Vec> { - (0..self.row_count) - .map(PascalsTriangle::row) - .collect() + (0..self.row_count).map(PascalsTriangle::row).collect() } pub fn row(number: u32) -> Vec { diff --git a/exercises/pascals-triangle/tests/pascals-triangle.rs b/exercises/pascals-triangle/tests/pascals-triangle.rs index d222a7056..fe2042bdc 100644 --- a/exercises/pascals-triangle/tests/pascals-triangle.rs +++ b/exercises/pascals-triangle/tests/pascals-triangle.rs @@ -1,5 +1,3 @@ -extern crate pascals_triangle; - use pascals_triangle::*; #[test] diff --git a/exercises/perfect-numbers/Cargo.toml b/exercises/perfect-numbers/Cargo.toml index 988b4aa32..ac43ba13d 100644 --- a/exercises/perfect-numbers/Cargo.toml +++ b/exercises/perfect-numbers/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "perfect_numbers" version = "1.1.0" diff --git a/exercises/perfect-numbers/tests/perfect-numbers.rs b/exercises/perfect-numbers/tests/perfect-numbers.rs index 25e01d3fb..a39fc52eb 100644 --- a/exercises/perfect-numbers/tests/perfect-numbers.rs +++ b/exercises/perfect-numbers/tests/perfect-numbers.rs @@ -1,5 +1,3 @@ -extern crate perfect_numbers; - use perfect_numbers::{classify, Classification}; macro_rules! tests { diff --git a/exercises/phone-number/Cargo.toml b/exercises/phone-number/Cargo.toml index a2c51c10a..82e5df44c 100644 --- a/exercises/phone-number/Cargo.toml +++ b/exercises/phone-number/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "phone-number" version = "1.6.1" diff --git a/exercises/phone-number/example.rs b/exercises/phone-number/example.rs index aa9023b93..1475693f4 100644 --- a/exercises/phone-number/example.rs +++ b/exercises/phone-number/example.rs @@ -5,8 +5,7 @@ pub fn number(user_number: &str) -> Option { if number_len < 10 || number_len > 11 - || (filtered_number.len() == 11 - && filtered_number.chars().nth(0).unwrap() != '1') + || (filtered_number.len() == 11 && filtered_number.chars().nth(0).unwrap() != '1') { return None; } diff --git a/exercises/phone-number/tests/phone-number.rs b/exercises/phone-number/tests/phone-number.rs index 6c0fc6bdf..2bde594e2 100644 --- a/exercises/phone-number/tests/phone-number.rs +++ b/exercises/phone-number/tests/phone-number.rs @@ -1,4 +1,4 @@ -extern crate phone_number as phone; +use phone_number as phone; fn process_clean_case(number: &str, expected: Option<&str>) { assert_eq!(phone::number(number), expected.map(|x| x.to_string())); diff --git a/exercises/pig-latin/Cargo-example.toml b/exercises/pig-latin/Cargo-example.toml index d10fdaca8..6452f6bea 100644 --- a/exercises/pig-latin/Cargo-example.toml +++ b/exercises/pig-latin/Cargo-example.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "pig-latin" version = "1.0.0" diff --git a/exercises/pig-latin/Cargo.toml b/exercises/pig-latin/Cargo.toml index 83e771e92..3a72f261e 100644 --- a/exercises/pig-latin/Cargo.toml +++ b/exercises/pig-latin/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "pig-latin" version = "1.0.0" diff --git a/exercises/pig-latin/tests/pig-latin.rs b/exercises/pig-latin/tests/pig-latin.rs index d55dded99..6e3812744 100644 --- a/exercises/pig-latin/tests/pig-latin.rs +++ b/exercises/pig-latin/tests/pig-latin.rs @@ -1,4 +1,4 @@ -extern crate pig_latin as pl; +use pig_latin as pl; #[test] fn test_word_beginning_with_a() { diff --git a/exercises/poker/Cargo-example.toml b/exercises/poker/Cargo-example.toml index f1c6c9f3f..57657757c 100644 --- a/exercises/poker/Cargo-example.toml +++ b/exercises/poker/Cargo-example.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "poker" version = "1.0.0" diff --git a/exercises/poker/Cargo.toml b/exercises/poker/Cargo.toml index 6e15b459c..647413b5d 100644 --- a/exercises/poker/Cargo.toml +++ b/exercises/poker/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "poker" version = "1.1.0" diff --git a/exercises/poker/example.rs b/exercises/poker/example.rs index 002914274..33a649b81 100644 --- a/exercises/poker/example.rs +++ b/exercises/poker/example.rs @@ -12,12 +12,10 @@ use counter::Counter; /// 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>(hands: &[&'a str]) -> Option> { - let mut hands = try_opt!( - hands - .iter() - .map(|source| Hand::try_from(source)) - .collect::>>() - ); + let mut hands = try_opt!(hands + .iter() + .map(|source| Hand::try_from(source)) + .collect::>>()); hands.sort_by(|a, b| a.partial_cmp(b).unwrap_or(Ordering::Less)); hands.last().map(|last| { hands @@ -39,7 +37,7 @@ enum Suit { impl Suit { fn try_from(source: &str) -> Option { - use Suit::*; + use crate::Suit::*; match source { "S" => Some(Spades), "C" => Some(Clubs), @@ -52,7 +50,7 @@ impl Suit { impl fmt::Display for Suit { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use Suit::*; + use crate::Suit::*; write!( f, "{}", @@ -77,7 +75,7 @@ enum Rank { impl Rank { fn try_from(source: &str) -> Option { - use Rank::*; + use crate::Rank::*; match source { "A" => Some(Ace), "K" => Some(King), @@ -97,7 +95,7 @@ impl Rank { } fn value(&self) -> usize { - use Rank::*; + use crate::Rank::*; match *self { Ace => 14, King => 13, @@ -110,7 +108,7 @@ impl Rank { impl fmt::Display for Rank { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use Rank::*; + use crate::Rank::*; let num_str; // early declaration to placate NLL of Number case write!( f, @@ -181,7 +179,8 @@ impl PokerHand { fn is_ace_low_straight(cards: &[Card]) -> bool { // special case: ace-low straight // still depends on the sorted precondition - cards[0].rank.value() == 2 && cards[4].rank == Rank::Ace + cards[0].rank.value() == 2 + && cards[4].rank == Rank::Ace && cards .windows(2) .take(3) // (0, 1), (1, 2), (2, 3) --> skips 4, ace @@ -195,7 +194,8 @@ impl PokerHand { let is_flush = suit_counter .most_common() .map(|(_suit, count)| count) - .next() == Some(5); + .next() + == Some(5); // Note that `is_straight` depends on a precondition: it only works // if the input `cards` are sorted by rank value ascending. let is_straight = cards @@ -250,12 +250,10 @@ struct Hand<'a> { impl<'a> Hand<'a> { fn try_from(source: &'a str) -> Option { - let mut cards = try_opt!( - source - .split_whitespace() - .map(|s| Card::try_from(s)) - .collect::>>() - ); + let mut cards = try_opt!(source + .split_whitespace() + .map(|s| Card::try_from(s)) + .collect::>>()); cards.sort_by(|a, b| a.partial_cmp(b).unwrap_or(Ordering::Less)); if cards.len() == 5 { Some(Hand { @@ -325,7 +323,7 @@ impl<'a> fmt::Display for Hand<'a> { impl<'a> PartialOrd for Hand<'a> { fn partial_cmp(&self, other: &Hand) -> Option { Some(self.hand_type.cmp(&other.hand_type).then_with(|| { - use PokerHand::*; + use crate::PokerHand::*; match self.hand_type { HighCard => self.cmp_high_card(other, 4), OnePair => self.cmp_cascade_by_freq(other), diff --git a/exercises/poker/tests/poker.rs b/exercises/poker/tests/poker.rs index 9f575de2d..b3d7b8ca4 100644 --- a/exercises/poker/tests/poker.rs +++ b/exercises/poker/tests/poker.rs @@ -1,4 +1,3 @@ -extern crate poker; use poker::winning_hands; use std::collections::HashSet; diff --git a/exercises/prime-factors/Cargo.toml b/exercises/prime-factors/Cargo.toml index 441b7fd6a..70727e601 100644 --- a/exercises/prime-factors/Cargo.toml +++ b/exercises/prime-factors/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "prime_factors" version = "1.1.0" diff --git a/exercises/prime-factors/tests/prime-factors.rs b/exercises/prime-factors/tests/prime-factors.rs index e5953cc55..aee6cdaaa 100644 --- a/exercises/prime-factors/tests/prime-factors.rs +++ b/exercises/prime-factors/tests/prime-factors.rs @@ -1,5 +1,3 @@ -extern crate prime_factors; - use prime_factors::factors; #[test] diff --git a/exercises/protein-translation/Cargo.toml b/exercises/protein-translation/Cargo.toml index c29ceeff6..12bb32a92 100644 --- a/exercises/protein-translation/Cargo.toml +++ b/exercises/protein-translation/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "protein-translation" version = "0.1.0" diff --git a/exercises/protein-translation/tests/proteins.rs b/exercises/protein-translation/tests/proteins.rs index 0f0665633..494aba130 100644 --- a/exercises/protein-translation/tests/proteins.rs +++ b/exercises/protein-translation/tests/proteins.rs @@ -1,4 +1,4 @@ -extern crate protein_translation as proteins; +use protein_translation as proteins; #[test] fn test_methionine() { diff --git a/exercises/proverb/Cargo.toml b/exercises/proverb/Cargo.toml index 5cd818522..4e09ea104 100644 --- a/exercises/proverb/Cargo.toml +++ b/exercises/proverb/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "proverb" version = "1.1.0" diff --git a/exercises/proverb/tests/proverb.rs b/exercises/proverb/tests/proverb.rs index f69782508..fbf8e8cea 100644 --- a/exercises/proverb/tests/proverb.rs +++ b/exercises/proverb/tests/proverb.rs @@ -1,5 +1,3 @@ -extern crate proverb; - use proverb::build_proverb; #[test] @@ -8,7 +6,8 @@ fn test_two_pieces() { let expected = vec![ "For want of a nail the shoe was lost.", "And all for the want of a nail.", - ].join("\n"); + ] + .join("\n"); assert_eq!(build_proverb(&input), expected); } @@ -21,7 +20,8 @@ fn test_three_pieces() { "For want of a nail the shoe was lost.", "For want of a shoe the horse was lost.", "And all for the want of a nail.", - ].join("\n"); + ] + .join("\n"); assert_eq!(build_proverb(&input), expected); } @@ -55,7 +55,8 @@ fn test_full() { "For want of a message the battle was lost.", "For want of a battle the kingdom was lost.", "And all for the want of a nail.", - ].join("\n"); + ] + .join("\n"); assert_eq!(build_proverb(&input), expected); } @@ -68,6 +69,7 @@ fn test_three_pieces_modernized() { "For want of a gun the soldier was lost.", "For want of a soldier the battle was lost.", "And all for the want of a pin.", - ].join("\n"); + ] + .join("\n"); assert_eq!(build_proverb(&input), expected); } diff --git a/exercises/pythagorean-triplet/Cargo.toml b/exercises/pythagorean-triplet/Cargo.toml index 1aec82db6..b0d9ae8fa 100644 --- a/exercises/pythagorean-triplet/Cargo.toml +++ b/exercises/pythagorean-triplet/Cargo.toml @@ -1,5 +1,6 @@ [dependencies] [package] +edition = "2018" name = "pythagorean_triplet" version = "1.0.0" diff --git a/exercises/pythagorean-triplet/tests/pythagorean-triplet.rs b/exercises/pythagorean-triplet/tests/pythagorean-triplet.rs index 3198ca26c..9dfb38d5f 100644 --- a/exercises/pythagorean-triplet/tests/pythagorean-triplet.rs +++ b/exercises/pythagorean-triplet/tests/pythagorean-triplet.rs @@ -1,5 +1,3 @@ -extern crate pythagorean_triplet; - use pythagorean_triplet::find; use std::{collections::HashSet, iter::FromIterator}; diff --git a/exercises/queen-attack/Cargo.toml b/exercises/queen-attack/Cargo.toml index 5103ef806..ffb4cd888 100644 --- a/exercises/queen-attack/Cargo.toml +++ b/exercises/queen-attack/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "queen-attack" version = "2.2.0" diff --git a/exercises/queen-attack/example.rs b/exercises/queen-attack/example.rs index dea80dbec..76808ae09 100644 --- a/exercises/queen-attack/example.rs +++ b/exercises/queen-attack/example.rs @@ -34,10 +34,7 @@ pub struct ChessPosition { impl ChessPosition { pub fn new(rank: i8, file: i8) -> Option { - let position = ChessPosition { - rank, - file, - }; + let position = ChessPosition { rank, file }; if position.is_valid() { Some(position) diff --git a/exercises/queen-attack/tests/queen-attack.rs b/exercises/queen-attack/tests/queen-attack.rs index 5b6caff6e..6b0eaeada 100644 --- a/exercises/queen-attack/tests/queen-attack.rs +++ b/exercises/queen-attack/tests/queen-attack.rs @@ -1,5 +1,3 @@ -extern crate queen_attack; - use queen_attack::*; #[test] diff --git a/exercises/rail-fence-cipher/Cargo.toml b/exercises/rail-fence-cipher/Cargo.toml index ff5617793..f6b8092c2 100644 --- a/exercises/rail-fence-cipher/Cargo.toml +++ b/exercises/rail-fence-cipher/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "rail_fence_cipher" version = "1.1.0" diff --git a/exercises/rail-fence-cipher/tests/rail-fence-cipher.rs b/exercises/rail-fence-cipher/tests/rail-fence-cipher.rs index c07f8c395..3170cb117 100644 --- a/exercises/rail-fence-cipher/tests/rail-fence-cipher.rs +++ b/exercises/rail-fence-cipher/tests/rail-fence-cipher.rs @@ -8,7 +8,6 @@ //! The tests do not expect any normalization or cleaning. //! That trade is tested in enough other exercises. -extern crate rail_fence_cipher; use rail_fence_cipher::*; /// Process a single test case for the property `encode` diff --git a/exercises/raindrops/Cargo.toml b/exercises/raindrops/Cargo.toml index 34a693845..f37aa78c8 100644 --- a/exercises/raindrops/Cargo.toml +++ b/exercises/raindrops/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "raindrops" version = "1.1.0" diff --git a/exercises/raindrops/tests/raindrops.rs b/exercises/raindrops/tests/raindrops.rs index 6e03780fa..22b69391b 100644 --- a/exercises/raindrops/tests/raindrops.rs +++ b/exercises/raindrops/tests/raindrops.rs @@ -1,4 +1,4 @@ -extern crate raindrops; +use raindrops; #[test] fn test_1() { diff --git a/exercises/react/Cargo.toml b/exercises/react/Cargo.toml index 1c2ac5a2f..d957c6cc4 100644 --- a/exercises/react/Cargo.toml +++ b/exercises/react/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "react" version = "2.0.0" diff --git a/exercises/react/example.rs b/exercises/react/example.rs index 21c4043c0..d75fb3e92 100644 --- a/exercises/react/example.rs +++ b/exercises/react/example.rs @@ -99,12 +99,16 @@ impl<'a, T: Copy + PartialEq> Reactor<'a, T> { // so that we don't perform an incorrect partial write. for &dep in dependencies { match dep { - CellID::Input(InputCellID(id)) => if id >= self.inputs.len() { - return Err(dep); - }, - CellID::Compute(ComputeCellID(id)) => if id >= self.computes.len() { - return Err(dep); - }, + CellID::Input(InputCellID(id)) => { + if id >= self.inputs.len() { + return Err(dep); + } + } + CellID::Compute(ComputeCellID(id)) => { + if id >= self.computes.len() { + return Err(dep); + } + } } } let new_id = ComputeCellID(self.computes.len()); diff --git a/exercises/react/tests/react.rs b/exercises/react/tests/react.rs index 65f71c914..cd26a361e 100644 --- a/exercises/react/tests/react.rs +++ b/exercises/react/tests/react.rs @@ -1,5 +1,3 @@ -extern crate react; - use react::*; #[test] @@ -172,11 +170,9 @@ fn compute_cells_fire_callbacks() { let output = reactor .create_compute(&[CellID::Input(input)], |v| v[0] + 1) .unwrap(); - assert!( - reactor - .add_callback(output, |v| cb.callback_called(v)) - .is_some() - ); + assert!(reactor + .add_callback(output, |v| cb.callback_called(v)) + .is_some()); assert!(reactor.set_value(input, 3)); cb.expect_to_have_been_called_with(4); } @@ -207,11 +203,9 @@ fn callbacks_only_fire_on_change() { |v| if v[0] < 3 { 111 } else { 222 }, ) .unwrap(); - assert!( - reactor - .add_callback(output, |v| cb.callback_called(v)) - .is_some() - ); + assert!(reactor + .add_callback(output, |v| cb.callback_called(v)) + .is_some()); assert!(reactor.set_value(input, 2)); cb.expect_not_to_have_been_called(); @@ -228,11 +222,9 @@ fn callbacks_can_be_called_multiple_times() { let output = reactor .create_compute(&[CellID::Input(input)], |v| v[0] + 1) .unwrap(); - assert!( - reactor - .add_callback(output, |v| cb.callback_called(v)) - .is_some() - ); + assert!(reactor + .add_callback(output, |v| cb.callback_called(v)) + .is_some()); assert!(reactor.set_value(input, 2)); cb.expect_to_have_been_called_with(3); @@ -253,16 +245,12 @@ fn callbacks_can_be_called_from_multiple_cells() { let minus_one = reactor .create_compute(&[CellID::Input(input)], |v| v[0] - 1) .unwrap(); - assert!( - reactor - .add_callback(plus_one, |v| cb1.callback_called(v)) - .is_some() - ); - assert!( - reactor - .add_callback(minus_one, |v| cb2.callback_called(v)) - .is_some() - ); + assert!(reactor + .add_callback(plus_one, |v| cb1.callback_called(v)) + .is_some()); + assert!(reactor + .add_callback(minus_one, |v| cb2.callback_called(v)) + .is_some()); assert!(reactor.set_value(input, 10)); cb1.expect_to_have_been_called_with(11); @@ -285,22 +273,18 @@ fn callbacks_can_be_added_and_removed() { let callback = reactor .add_callback(output, |v| cb1.callback_called(v)) .unwrap(); - assert!( - reactor - .add_callback(output, |v| cb2.callback_called(v)) - .is_some() - ); + assert!(reactor + .add_callback(output, |v| cb2.callback_called(v)) + .is_some()); assert!(reactor.set_value(input, 31)); cb1.expect_to_have_been_called_with(32); cb2.expect_to_have_been_called_with(32); assert!(reactor.remove_callback(output, callback).is_ok()); - assert!( - reactor - .add_callback(output, |v| cb3.callback_called(v)) - .is_some() - ); + assert!(reactor + .add_callback(output, |v| cb3.callback_called(v)) + .is_some()); assert!(reactor.set_value(input, 41)); cb1.expect_not_to_have_been_called(); @@ -322,11 +306,9 @@ fn removing_a_callback_multiple_times_doesnt_interfere_with_other_callbacks() { let callback = reactor .add_callback(output, |v| cb1.callback_called(v)) .unwrap(); - assert!( - reactor - .add_callback(output, |v| cb2.callback_called(v)) - .is_some() - ); + assert!(reactor + .add_callback(output, |v| cb2.callback_called(v)) + .is_some()); // We want the first remove to be Ok, but the others should be errors. assert!(reactor.remove_callback(output, callback).is_ok()); for _ in 1..5 { @@ -362,11 +344,9 @@ fn callbacks_should_only_be_called_once_even_if_multiple_dependencies_change() { |v| v[0] * v[1], ) .unwrap(); - assert!( - reactor - .add_callback(output, |v| cb.callback_called(v)) - .is_some() - ); + assert!(reactor + .add_callback(output, |v| cb.callback_called(v)) + .is_some()); assert!(reactor.set_value(input, 4)); cb.expect_to_have_been_called_with(10); } @@ -389,11 +369,9 @@ fn callbacks_should_not_be_called_if_dependencies_change_but_output_value_doesnt |v| v[0] - v[1], ) .unwrap(); - assert!( - reactor - .add_callback(always_two, |v| cb.callback_called(v)) - .is_some() - ); + assert!(reactor + .add_callback(always_two, |v| cb.callback_called(v)) + .is_some()); for i in 2..5 { assert!(reactor.set_value(input, i)); cb.expect_not_to_have_been_called(); diff --git a/exercises/rectangles/Cargo.toml b/exercises/rectangles/Cargo.toml index 3fa7ec041..d692cc168 100644 --- a/exercises/rectangles/Cargo.toml +++ b/exercises/rectangles/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "rectangles" version = "1.1.0" diff --git a/exercises/rectangles/tests/rectangles.rs b/exercises/rectangles/tests/rectangles.rs index b61dc4a95..e079f0599 100644 --- a/exercises/rectangles/tests/rectangles.rs +++ b/exercises/rectangles/tests/rectangles.rs @@ -1,4 +1,4 @@ -extern crate rectangles; + use rectangles::count; diff --git a/exercises/reverse-string/Cargo.toml b/exercises/reverse-string/Cargo.toml index 034018e3e..ad556d3af 100644 --- a/exercises/reverse-string/Cargo.toml +++ b/exercises/reverse-string/Cargo.toml @@ -4,5 +4,6 @@ grapheme = [] [package] +edition = "2018" name = "reverse_string" version = "1.1.0" diff --git a/exercises/reverse-string/tests/reverse-string.rs b/exercises/reverse-string/tests/reverse-string.rs index d6de3bc01..5b1145223 100644 --- a/exercises/reverse-string/tests/reverse-string.rs +++ b/exercises/reverse-string/tests/reverse-string.rs @@ -5,7 +5,6 @@ //! [script]: https://github.com/exercism/rust/blob/b829ce2/bin/init_exercise.py //! [canonical-data]: https://raw.githubusercontent.com/exercism/problem-specifications/master/exercises/reverse-string/canonical_data.json -extern crate reverse_string; use reverse_string::*; /// Process a single test case for the property `reverse` diff --git a/exercises/rna-transcription/Cargo.toml b/exercises/rna-transcription/Cargo.toml index 1b205b181..00b55408e 100644 --- a/exercises/rna-transcription/Cargo.toml +++ b/exercises/rna-transcription/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "rna-transcription" version = "1.0.0" diff --git a/exercises/rna-transcription/tests/rna-transcription.rs b/exercises/rna-transcription/tests/rna-transcription.rs index 76138a94c..feed29b34 100644 --- a/exercises/rna-transcription/tests/rna-transcription.rs +++ b/exercises/rna-transcription/tests/rna-transcription.rs @@ -1,4 +1,4 @@ -extern crate rna_transcription as dna; +use rna_transcription as dna; #[test] fn test_valid_dna_input() { diff --git a/exercises/robot-name/Cargo-example.toml b/exercises/robot-name/Cargo-example.toml index 0a96b50b8..947865342 100644 --- a/exercises/robot-name/Cargo-example.toml +++ b/exercises/robot-name/Cargo-example.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "robot-name" version = "0.0.0" diff --git a/exercises/robot-name/Cargo.toml b/exercises/robot-name/Cargo.toml index 789f265e7..897aa15bb 100644 --- a/exercises/robot-name/Cargo.toml +++ b/exercises/robot-name/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "robot-name" version = "0.0.0" diff --git a/exercises/robot-name/tests/robot-name.rs b/exercises/robot-name/tests/robot-name.rs index 27236fa75..bfe0269ac 100644 --- a/exercises/robot-name/tests/robot-name.rs +++ b/exercises/robot-name/tests/robot-name.rs @@ -1,4 +1,4 @@ -extern crate robot_name as robot; +use robot_name as robot; fn assert_name_matches_pattern(n: &str) { assert!(n.len() == 5, "name is exactly 5 characters long"); diff --git a/exercises/robot-simulator/Cargo.toml b/exercises/robot-simulator/Cargo.toml index dd962d6c5..7d5b75fca 100644 --- a/exercises/robot-simulator/Cargo.toml +++ b/exercises/robot-simulator/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "robot-simulator" version = "2.2.0" diff --git a/exercises/robot-simulator/tests/robot-simulator.rs b/exercises/robot-simulator/tests/robot-simulator.rs index 81528ba76..1c33c2f18 100644 --- a/exercises/robot-simulator/tests/robot-simulator.rs +++ b/exercises/robot-simulator/tests/robot-simulator.rs @@ -1,5 +1,3 @@ -extern crate robot_simulator; - use robot_simulator::*; #[test] diff --git a/exercises/roman-numerals/Cargo.toml b/exercises/roman-numerals/Cargo.toml index 6ae5e099d..8f7918cac 100644 --- a/exercises/roman-numerals/Cargo.toml +++ b/exercises/roman-numerals/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "roman-numerals" version = "1.0.0" diff --git a/exercises/roman-numerals/src/lib.rs b/exercises/roman-numerals/src/lib.rs index 21d8072c8..96ed9acef 100644 --- a/exercises/roman-numerals/src/lib.rs +++ b/exercises/roman-numerals/src/lib.rs @@ -3,7 +3,7 @@ use std::fmt::{Display, Formatter, Result}; pub struct Roman; impl Display for Roman { - fn fmt(&self, _f: &mut Formatter) -> Result { + fn fmt(&self, _f: &mut Formatter<'_>) -> Result { unimplemented!("Return a roman-numeral string representation of the Roman object"); } } diff --git a/exercises/roman-numerals/tests/roman-numerals.rs b/exercises/roman-numerals/tests/roman-numerals.rs index c4e302a86..cb175fec2 100644 --- a/exercises/roman-numerals/tests/roman-numerals.rs +++ b/exercises/roman-numerals/tests/roman-numerals.rs @@ -1,5 +1,3 @@ -extern crate roman_numerals; - use roman_numerals::*; #[test] diff --git a/exercises/rotational-cipher/Cargo.toml b/exercises/rotational-cipher/Cargo.toml index aabf2b132..19647c6de 100644 --- a/exercises/rotational-cipher/Cargo.toml +++ b/exercises/rotational-cipher/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "rotational-cipher" version = "1.0.0" diff --git a/exercises/rotational-cipher/tests/rotational-cipher.rs b/exercises/rotational-cipher/tests/rotational-cipher.rs index 7405062ad..64f0d66c4 100644 --- a/exercises/rotational-cipher/tests/rotational-cipher.rs +++ b/exercises/rotational-cipher/tests/rotational-cipher.rs @@ -1,4 +1,4 @@ -extern crate rotational_cipher as cipher; +use rotational_cipher as cipher; #[test] fn rotate_a_1() { diff --git a/exercises/run-length-encoding/Cargo.toml b/exercises/run-length-encoding/Cargo.toml index a6866b5d1..f805b78c8 100644 --- a/exercises/run-length-encoding/Cargo.toml +++ b/exercises/run-length-encoding/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "run-length-encoding" version = "1.1.0" diff --git a/exercises/run-length-encoding/tests/run-length-encoding.rs b/exercises/run-length-encoding/tests/run-length-encoding.rs index 70359920c..bcb208e36 100644 --- a/exercises/run-length-encoding/tests/run-length-encoding.rs +++ b/exercises/run-length-encoding/tests/run-length-encoding.rs @@ -1,4 +1,4 @@ -extern crate run_length_encoding as rle; +use run_length_encoding as rle; // encoding tests diff --git a/exercises/saddle-points/Cargo.toml b/exercises/saddle-points/Cargo.toml index fc43d00f7..5f262e2dc 100644 --- a/exercises/saddle-points/Cargo.toml +++ b/exercises/saddle-points/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "saddle-points" version = "1.3.0" diff --git a/exercises/saddle-points/tests/saddle-points.rs b/exercises/saddle-points/tests/saddle-points.rs index 8fd853e13..287c3dad7 100644 --- a/exercises/saddle-points/tests/saddle-points.rs +++ b/exercises/saddle-points/tests/saddle-points.rs @@ -1,4 +1,4 @@ -extern crate saddle_points; +use saddle_points; use saddle_points::find_saddle_points; @@ -11,11 +11,7 @@ fn find_sorted_saddle_points(input: &[Vec]) -> Vec<(usize, usize)> { #[test] fn identify_single_saddle_point() { - let input = vec![ - vec![9, 8, 7], - vec![5, 3, 2], - vec![6, 6, 7], - ]; + let input = vec![vec![9, 8, 7], vec![5, 3, 2], vec![6, 6, 7]]; assert_eq!(vec![(1, 0)], find_saddle_points(&input)); } @@ -30,11 +26,7 @@ fn identify_empty_matrix() { #[test] #[ignore] fn identify_lack_of_saddle_point() { - let input = vec![ - vec![1, 2, 3], - vec![3, 1, 2], - vec![2, 3, 1], - ]; + let input = vec![vec![1, 2, 3], vec![3, 1, 2], vec![2, 3, 1]]; let expected: Vec<(usize, usize)> = Vec::new(); assert_eq!(expected, find_saddle_points(&input)); } @@ -42,11 +34,7 @@ fn identify_lack_of_saddle_point() { #[test] #[ignore] fn multiple_saddle_points_in_col() { - let input = vec![ - vec![4, 5, 4], - vec![3, 5, 5], - vec![1, 5, 4], - ]; + let input = vec![vec![4, 5, 4], vec![3, 5, 5], vec![1, 5, 4]]; assert_eq!( vec![(0, 1), (1, 1), (2, 1)], find_sorted_saddle_points(&input) @@ -56,11 +44,7 @@ fn multiple_saddle_points_in_col() { #[test] #[ignore] fn multiple_saddle_points_in_row() { - let input = vec![ - vec![6, 7, 8], - vec![5, 5, 5], - vec![7, 5, 6], - ]; + let input = vec![vec![6, 7, 8], vec![5, 5, 5], vec![7, 5, 6]]; assert_eq!( vec![(1, 0), (1, 1), (1, 2)], find_sorted_saddle_points(&input) @@ -70,11 +54,7 @@ fn multiple_saddle_points_in_row() { #[test] #[ignore] fn identify_bottom_right_saddle_point() { - let input = vec![ - vec![8, 7, 9], - vec![6, 7, 6], - vec![3, 2, 5], - ]; + let input = vec![vec![8, 7, 9], vec![6, 7, 6], vec![3, 2, 5]]; assert_eq!(vec![(2, 2)], find_saddle_points(&input)); } @@ -82,54 +62,47 @@ fn identify_bottom_right_saddle_point() { #[test] #[ignore] fn non_square_matrix_high() { - let input = vec![ - vec![1, 5], - vec![3, 6], - vec![2, 7], - vec![3, 8], - ]; + let input = vec![vec![1, 5], vec![3, 6], vec![2, 7], vec![3, 8]]; assert_eq!(vec![(0, 1)], find_saddle_points(&input)); } #[test] #[ignore] fn non_square_matrix_wide() { - let input = vec![ - vec![3, 1, 3], - vec![3, 2, 4] - ]; + let input = vec![vec![3, 1, 3], vec![3, 2, 4]]; assert_eq!(vec![(0, 0), (0, 2)], find_sorted_saddle_points(&input)); } #[test] #[ignore] fn single_column_matrix() { - let input = vec![ - vec![2], - vec![1], - vec![4], - vec![1], - ]; + let input = vec![vec![2], vec![1], vec![4], vec![1]]; assert_eq!(vec![(1, 0), (3, 0)], find_sorted_saddle_points(&input)); } #[test] #[ignore] fn single_row_matrix() { - let input = vec![ - vec![2, 5, 3, 5], - ]; + let input = vec![vec![2, 5, 3, 5]]; assert_eq!(vec![(0, 1), (0, 3)], find_sorted_saddle_points(&input)); } #[test] #[ignore] fn identify_all_saddle_points() { - let input = vec![ - vec![5, 5, 5], - vec![5, 5, 5], - vec![5, 5, 5], - ]; - assert_eq!(vec![(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)], find_saddle_points(&input)); + let input = vec![vec![5, 5, 5], vec![5, 5, 5], vec![5, 5, 5]]; + assert_eq!( + vec![ + (0, 0), + (0, 1), + (0, 2), + (1, 0), + (1, 1), + (1, 2), + (2, 0), + (2, 1), + (2, 2) + ], + find_saddle_points(&input) + ); } - diff --git a/exercises/say/Cargo.toml b/exercises/say/Cargo.toml index 852b991d1..48983e26b 100644 --- a/exercises/say/Cargo.toml +++ b/exercises/say/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "say" version = "1.2.0" diff --git a/exercises/say/tests/say.rs b/exercises/say/tests/say.rs index ea22c50e6..92a682ba5 100644 --- a/exercises/say/tests/say.rs +++ b/exercises/say/tests/say.rs @@ -1,4 +1,4 @@ -extern crate say; +use say; // Note: No tests created using 'and' with numbers. // Apparently Most American English does not use the 'and' with numbers, diff --git a/exercises/scale-generator/Cargo-example.toml b/exercises/scale-generator/Cargo-example.toml index a67d9247c..e029a22af 100644 --- a/exercises/scale-generator/Cargo-example.toml +++ b/exercises/scale-generator/Cargo-example.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "scale_generator" version = "1.0.0" diff --git a/exercises/scale-generator/Cargo.toml b/exercises/scale-generator/Cargo.toml index f07d90d27..f59bf1622 100644 --- a/exercises/scale-generator/Cargo.toml +++ b/exercises/scale-generator/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "scale_generator" version = "2.0.0" diff --git a/exercises/scale-generator/example.rs b/exercises/scale-generator/example.rs index 0aa2be63e..5f1dc5d7b 100644 --- a/exercises/scale-generator/example.rs +++ b/exercises/scale-generator/example.rs @@ -119,7 +119,7 @@ pub mod interval { } pub mod note { - use interval::Interval; + use crate::Interval; use num_traits::{FromPrimitive, ToPrimitive}; use std::fmt; use std::ops::AddAssign; @@ -305,7 +305,8 @@ pub mod note { Semitone::from_i8( (SEMITONES + n.tonic.to_i8().unwrap() + n.accidental.map_or(0, |a| a.to_i8())) % SEMITONES, - ).expect("must have valid semitone") + ) + .expect("must have valid semitone") } } @@ -314,8 +315,9 @@ pub mod note { *self = Semitone::from_i8( (SEMITONES + Semitone::from(*self).to_i8().unwrap() + rhs.to_i8().unwrap()) % SEMITONES, - ).unwrap() - .into(); + ) + .unwrap() + .into(); } } diff --git a/exercises/scale-generator/tests/scale-generator.rs b/exercises/scale-generator/tests/scale-generator.rs index 55970ed5b..9f8c3c930 100644 --- a/exercises/scale-generator/tests/scale-generator.rs +++ b/exercises/scale-generator/tests/scale-generator.rs @@ -5,7 +5,6 @@ //! [script]: https://github.com/exercism/rust/blob/master/bin/init_exercise.py //! [canonical-data]: https://raw.githubusercontent.com/exercism/problem-specifications/master/exercises/scale-generator/canonical_data.json -extern crate scale_generator; use scale_generator::*; /// Process a single test case for the property `chromatic` @@ -36,7 +35,7 @@ fn test_chromatic_scale_with_sharps() { process_chromatic_case( "C", &[ - "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" + "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B", ], ); } @@ -48,7 +47,7 @@ fn test_chromatic_scale_with_flats() { process_chromatic_case( "F", &[ - "F", "Gb", "G", "Ab", "A", "Bb", "B", "C", "Db", "D", "Eb", "E" + "F", "Gb", "G", "Ab", "A", "Bb", "B", "C", "Db", "D", "Eb", "E", ], ); } diff --git a/exercises/scrabble-score/Cargo.toml b/exercises/scrabble-score/Cargo.toml index 70bb582f7..e25de5d5b 100644 --- a/exercises/scrabble-score/Cargo.toml +++ b/exercises/scrabble-score/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "scrabble-score" version = "1.1.0" diff --git a/exercises/scrabble-score/tests/scrabble-score.rs b/exercises/scrabble-score/tests/scrabble-score.rs index 03585a03f..ab7439a92 100644 --- a/exercises/scrabble-score/tests/scrabble-score.rs +++ b/exercises/scrabble-score/tests/scrabble-score.rs @@ -1,5 +1,3 @@ -extern crate scrabble_score; - use scrabble_score::*; #[test] diff --git a/exercises/series/Cargo.toml b/exercises/series/Cargo.toml index f8da3cd2d..523a7795f 100644 --- a/exercises/series/Cargo.toml +++ b/exercises/series/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "series" version = "0.1.0" diff --git a/exercises/series/tests/series.rs b/exercises/series/tests/series.rs index ce53c3666..bbaf8a7c5 100644 --- a/exercises/series/tests/series.rs +++ b/exercises/series/tests/series.rs @@ -1,4 +1,3 @@ -extern crate series; use series::*; #[test] diff --git a/exercises/sieve/Cargo.toml b/exercises/sieve/Cargo.toml index 1389a4a13..3af912356 100644 --- a/exercises/sieve/Cargo.toml +++ b/exercises/sieve/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "sieve" version = "1.1.0" diff --git a/exercises/sieve/tests/sieve.rs b/exercises/sieve/tests/sieve.rs index cafff543d..9b94538c8 100644 --- a/exercises/sieve/tests/sieve.rs +++ b/exercises/sieve/tests/sieve.rs @@ -1,4 +1,4 @@ -extern crate sieve; +use sieve; #[test] fn limit_lower_than_the_first_prime() { diff --git a/exercises/simple-cipher/Cargo.toml b/exercises/simple-cipher/Cargo.toml index 504454426..fdc32dfdb 100644 --- a/exercises/simple-cipher/Cargo.toml +++ b/exercises/simple-cipher/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "simple-cipher" version = "0.0.0" diff --git a/exercises/simple-cipher/tests/simple-cipher.rs b/exercises/simple-cipher/tests/simple-cipher.rs index 463a506e9..7ebb2be1b 100644 --- a/exercises/simple-cipher/tests/simple-cipher.rs +++ b/exercises/simple-cipher/tests/simple-cipher.rs @@ -1,4 +1,3 @@ -extern crate simple_cipher; use simple_cipher::*; use std::collections::HashSet; diff --git a/exercises/simple-linked-list/Cargo.toml b/exercises/simple-linked-list/Cargo.toml index a1c07edcc..25a62e7bf 100644 --- a/exercises/simple-linked-list/Cargo.toml +++ b/exercises/simple-linked-list/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "simple_linked_list" version = "0.1.0" diff --git a/exercises/simple-linked-list/tests/simple-linked-list.rs b/exercises/simple-linked-list/tests/simple-linked-list.rs index 84ddd5a1c..3bb926c65 100644 --- a/exercises/simple-linked-list/tests/simple-linked-list.rs +++ b/exercises/simple-linked-list/tests/simple-linked-list.rs @@ -1,5 +1,3 @@ -extern crate simple_linked_list; - use simple_linked_list::SimpleLinkedList; #[test] diff --git a/exercises/space-age/Cargo.toml b/exercises/space-age/Cargo.toml index 2dde0e801..6f68722fb 100644 --- a/exercises/space-age/Cargo.toml +++ b/exercises/space-age/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "space-age" version = "1.1.0" diff --git a/exercises/space-age/tests/space-age.rs b/exercises/space-age/tests/space-age.rs index 29c660299..8e5400ae6 100644 --- a/exercises/space-age/tests/space-age.rs +++ b/exercises/space-age/tests/space-age.rs @@ -1,5 +1,3 @@ -extern crate space_age; - use space_age::*; fn assert_in_delta(expected: f64, actual: f64) { diff --git a/exercises/spiral-matrix/Cargo.toml b/exercises/spiral-matrix/Cargo.toml index a12046f0b..a4e254de5 100644 --- a/exercises/spiral-matrix/Cargo.toml +++ b/exercises/spiral-matrix/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "spiral-matrix" version = "1.1.0" diff --git a/exercises/spiral-matrix/tests/spiral-matrix.rs b/exercises/spiral-matrix/tests/spiral-matrix.rs index f3abdfdde..6182ee569 100644 --- a/exercises/spiral-matrix/tests/spiral-matrix.rs +++ b/exercises/spiral-matrix/tests/spiral-matrix.rs @@ -1,4 +1,3 @@ -extern crate spiral_matrix; use spiral_matrix::*; #[test] diff --git a/exercises/sublist/Cargo.toml b/exercises/sublist/Cargo.toml index 7f04d9d8f..7b11434d1 100644 --- a/exercises/sublist/Cargo.toml +++ b/exercises/sublist/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "sublist" version = "0.0.0" diff --git a/exercises/sublist/tests/sublist.rs b/exercises/sublist/tests/sublist.rs index eb02edc5d..87390a327 100644 --- a/exercises/sublist/tests/sublist.rs +++ b/exercises/sublist/tests/sublist.rs @@ -1,5 +1,3 @@ -extern crate sublist; - use sublist::{sublist, Comparison}; #[test] diff --git a/exercises/sum-of-multiples/Cargo.toml b/exercises/sum-of-multiples/Cargo.toml index 715333e01..a00645901 100644 --- a/exercises/sum-of-multiples/Cargo.toml +++ b/exercises/sum-of-multiples/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "sum-of-multiples" version = "1.5.0" diff --git a/exercises/sum-of-multiples/tests/sum-of-multiples.rs b/exercises/sum-of-multiples/tests/sum-of-multiples.rs index d66f20396..1e64646f1 100644 --- a/exercises/sum-of-multiples/tests/sum-of-multiples.rs +++ b/exercises/sum-of-multiples/tests/sum-of-multiples.rs @@ -1,5 +1,3 @@ -extern crate sum_of_multiples; - use sum_of_multiples::*; #[test] diff --git a/exercises/tournament/Cargo.toml b/exercises/tournament/Cargo.toml index d20c2e93a..b1e61cea3 100644 --- a/exercises/tournament/Cargo.toml +++ b/exercises/tournament/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "tournament" version = "1.4.0" diff --git a/exercises/tournament/tests/tournament.rs b/exercises/tournament/tests/tournament.rs index 22dfdec1f..649256040 100644 --- a/exercises/tournament/tests/tournament.rs +++ b/exercises/tournament/tests/tournament.rs @@ -1,4 +1,4 @@ -extern crate tournament; +use tournament; #[test] fn just_the_header_if_no_input() { diff --git a/exercises/triangle/Cargo.toml b/exercises/triangle/Cargo.toml index 3e3773889..4042a35b4 100644 --- a/exercises/triangle/Cargo.toml +++ b/exercises/triangle/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "triangle" version = "0.0.0" diff --git a/exercises/triangle/tests/triangle.rs b/exercises/triangle/tests/triangle.rs index fe4e0dfc6..87e69defc 100644 --- a/exercises/triangle/tests/triangle.rs +++ b/exercises/triangle/tests/triangle.rs @@ -1,5 +1,3 @@ -extern crate triangle; - use triangle::*; #[test] diff --git a/exercises/two-bucket/Cargo.toml b/exercises/two-bucket/Cargo.toml index a32a8744c..79a5c77b3 100644 --- a/exercises/two-bucket/Cargo.toml +++ b/exercises/two-bucket/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "two-bucket" version = "1.4.0" diff --git a/exercises/two-bucket/tests/two-bucket.rs b/exercises/two-bucket/tests/two-bucket.rs index 365d489df..bd1ec1c15 100644 --- a/exercises/two-bucket/tests/two-bucket.rs +++ b/exercises/two-bucket/tests/two-bucket.rs @@ -1,5 +1,3 @@ -extern crate two_bucket; - use two_bucket::{solve, Bucket, BucketStats}; #[test] diff --git a/exercises/two-fer/Cargo.toml b/exercises/two-fer/Cargo.toml index c80ccc6a8..4f5f029ea 100644 --- a/exercises/two-fer/Cargo.toml +++ b/exercises/two-fer/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "twofer" version = "1.2.0" diff --git a/exercises/two-fer/tests/two-fer.rs b/exercises/two-fer/tests/two-fer.rs index 3946d7c11..29196cfb0 100644 --- a/exercises/two-fer/tests/two-fer.rs +++ b/exercises/two-fer/tests/two-fer.rs @@ -1,4 +1,3 @@ -extern crate twofer; use twofer::twofer; #[test] diff --git a/exercises/variable-length-quantity/Cargo.toml b/exercises/variable-length-quantity/Cargo.toml index 7af4a7fe6..54173dea1 100644 --- a/exercises/variable-length-quantity/Cargo.toml +++ b/exercises/variable-length-quantity/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "variable-length-quantity" version = "1.2.0" diff --git a/exercises/variable-length-quantity/tests/variable-length-quantity.rs b/exercises/variable-length-quantity/tests/variable-length-quantity.rs index c259a29ed..b2e3e7e29 100644 --- a/exercises/variable-length-quantity/tests/variable-length-quantity.rs +++ b/exercises/variable-length-quantity/tests/variable-length-quantity.rs @@ -1,4 +1,4 @@ -extern crate variable_length_quantity as vlq; +use variable_length_quantity as vlq; #[test] fn to_single_byte() { diff --git a/exercises/word-count/Cargo.toml b/exercises/word-count/Cargo.toml index 57ab6b6e9..3d0b1c0e9 100644 --- a/exercises/word-count/Cargo.toml +++ b/exercises/word-count/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "word-count" version = "1.2.0" diff --git a/exercises/word-count/tests/word-count.rs b/exercises/word-count/tests/word-count.rs index 2639033b1..4c57e0ca2 100644 --- a/exercises/word-count/tests/word-count.rs +++ b/exercises/word-count/tests/word-count.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -extern crate word_count; +use word_count; fn check_word_count(s: &str, pairs: &[(&str, u32)]) { // The reason for the awkward code in here is to ensure that the failure @@ -38,19 +38,13 @@ fn test_count_multiple_occurrences() { #[test] #[ignore] fn cramped_lists() { - check_word_count( - "one,two,three", - &[("one", 1), ("two", 1), ("three", 1)], - ); + check_word_count("one,two,three", &[("one", 1), ("two", 1), ("three", 1)]); } #[test] #[ignore] fn expanded_lists() { - check_word_count( - "one\ntwo\nthree", - &[("one", 1), ("two", 1), ("three", 1)], - ); + check_word_count("one\ntwo\nthree", &[("one", 1), ("two", 1), ("three", 1)]); } #[test] @@ -119,6 +113,6 @@ fn with_quotations() { fn multiple_spaces_not_detected_as_a_word() { check_word_count( " multiple whitespaces", - &[("multiple", 1), ("whitespaces", 1)] + &[("multiple", 1), ("whitespaces", 1)], ); } diff --git a/exercises/wordy/Cargo.toml b/exercises/wordy/Cargo.toml index 3dd5e2ff9..1138389d9 100644 --- a/exercises/wordy/Cargo.toml +++ b/exercises/wordy/Cargo.toml @@ -1,3 +1,4 @@ [package] +edition = "2018" name = "wordy" version = "1.5.0" diff --git a/exercises/wordy/example.rs b/exercises/wordy/example.rs index e4a089fb9..2717303a1 100644 --- a/exercises/wordy/example.rs +++ b/exercises/wordy/example.rs @@ -13,7 +13,9 @@ fn apply_op<'a, 'b>(num1: i32, words: &'a [Token<'b>]) -> Option<(i32, &'a [Toke let (op, num2) = op_and_num.split_at(number_pos); let num2 = match num2 { [Token::Number(i)] => i, - _ => unreachable!("We split at a Number above, so num2 is surely a single-element slice w/ a number"), + _ => unreachable!( + "We split at a Number above, so num2 is surely a single-element slice w/ a number" + ), }; match op { [Token::NonNumber("plus")] => Some(num1 + num2), @@ -21,26 +23,27 @@ fn apply_op<'a, 'b>(num1: i32, words: &'a [Token<'b>]) -> Option<(i32, &'a [Toke [Token::NonNumber("multiplied"), Token::NonNumber("by")] => Some(num1 * num2), [Token::NonNumber("divided"), Token::NonNumber("by")] => Some(num1 / num2), _ => None, - }.map(|n| (n, remainder)) + } + .map(|n| (n, remainder)) } pub fn answer(c: &str) -> Option { - let words = c.trim_end_matches('?').split_whitespace().map(|word| { - if let Ok(i) = word.parse::() { - Token::Number(i) - } else { - Token::NonNumber(word) - } - }).collect::>(); + let words = c + .trim_end_matches('?') + .split_whitespace() + .map(|word| { + if let Ok(i) = word.parse::() { + Token::Number(i) + } else { + Token::NonNumber(word) + } + }) + .collect::>(); if words.len() < 3 { return None; } let mut result: i32 = match words[0..3] { - [ - Token::NonNumber("What"), - Token::NonNumber("is"), - Token::Number(i), - ] => i, + [Token::NonNumber("What"), Token::NonNumber("is"), Token::Number(i)] => i, _ => return None, }; let mut words = words.split_at(3).1; diff --git a/exercises/wordy/tests/wordy.rs b/exercises/wordy/tests/wordy.rs index 3052a3306..6e839487f 100644 --- a/exercises/wordy/tests/wordy.rs +++ b/exercises/wordy/tests/wordy.rs @@ -1,5 +1,3 @@ -extern crate wordy; - use wordy::answer; #[test]