summaryrefslogtreecommitdiff
path: root/exercises/18_iterators
diff options
context:
space:
mode:
Diffstat (limited to 'exercises/18_iterators')
-rw-r--r--exercises/18_iterators/iterators1.rs32
-rw-r--r--exercises/18_iterators/iterators2.rs5
-rw-r--r--exercises/18_iterators/iterators3.rs5
-rw-r--r--exercises/18_iterators/iterators4.rs6
-rw-r--r--exercises/18_iterators/iterators5.rs5
5 files changed, 18 insertions, 35 deletions
diff --git a/exercises/18_iterators/iterators1.rs b/exercises/18_iterators/iterators1.rs
index 7ec7da2..52b704d 100644
--- a/exercises/18_iterators/iterators1.rs
+++ b/exercises/18_iterators/iterators1.rs
@@ -1,24 +1,28 @@
-// iterators1.rs
-//
// When performing operations on elements within a collection, iterators are
// essential. This module helps you get familiar with the structure of using an
// iterator and how to go through elements within an iterable collection.
//
// Make me compile by filling in the `???`s
-//
-// Execute `rustlings hint iterators1` or use the `hint` watch subcommand for a
-// hint.
-#[test]
fn main() {
- let my_fav_fruits = vec!["banana", "custard apple", "avocado", "peach", "raspberry"];
+ // You can optionally experiment here.
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn iterators() {
+ let my_fav_fruits = vec!["banana", "custard apple", "avocado", "peach", "raspberry"];
- let mut my_iterable_fav_fruits = ???; // TODO: Step 1
+ let mut my_iterable_fav_fruits = ???; // TODO: Step 1
- assert_eq!(my_iterable_fav_fruits.next(), Some(&"banana"));
- assert_eq!(my_iterable_fav_fruits.next(), ???); // TODO: Step 2
- assert_eq!(my_iterable_fav_fruits.next(), Some(&"avocado"));
- assert_eq!(my_iterable_fav_fruits.next(), ???); // TODO: Step 3
- assert_eq!(my_iterable_fav_fruits.next(), Some(&"raspberry"));
- assert_eq!(my_iterable_fav_fruits.next(), ???); // TODO: Step 4
+ assert_eq!(my_iterable_fav_fruits.next(), Some(&"banana"));
+ assert_eq!(my_iterable_fav_fruits.next(), ???); // TODO: Step 2
+ assert_eq!(my_iterable_fav_fruits.next(), Some(&"avocado"));
+ assert_eq!(my_iterable_fav_fruits.next(), ???); // TODO: Step 3
+ assert_eq!(my_iterable_fav_fruits.next(), Some(&"raspberry"));
+ assert_eq!(my_iterable_fav_fruits.next(), ???); // TODO: Step 4
+ }
}
diff --git a/exercises/18_iterators/iterators2.rs b/exercises/18_iterators/iterators2.rs
index 0ebd69a..df1fa83 100644
--- a/exercises/18_iterators/iterators2.rs
+++ b/exercises/18_iterators/iterators2.rs
@@ -1,10 +1,5 @@
-// iterators2.rs
-//
// In this exercise, you'll learn some of the unique advantages that iterators
// can offer. Follow the steps to complete the exercise.
-//
-// Execute `rustlings hint iterators2` or use the `hint` watch subcommand for a
-// hint.
// Step 1.
// Complete the `capitalize_first` function.
diff --git a/exercises/18_iterators/iterators3.rs b/exercises/18_iterators/iterators3.rs
index 3f5923c..9f106aa 100644
--- a/exercises/18_iterators/iterators3.rs
+++ b/exercises/18_iterators/iterators3.rs
@@ -1,13 +1,8 @@
-// iterators3.rs
-//
// This is a bigger exercise than most of the others! You can do it! Here is
// your mission, should you choose to accept it:
// 1. Complete the divide function to get the first four tests to pass.
// 2. Get the remaining tests to pass by completing the result_with_list and
// list_of_results functions.
-//
-// Execute `rustlings hint iterators3` or use the `hint` watch subcommand for a
-// hint.
#[derive(Debug, PartialEq, Eq)]
pub enum DivisionError {
diff --git a/exercises/18_iterators/iterators4.rs b/exercises/18_iterators/iterators4.rs
index 8fc8792..60c7b8d 100644
--- a/exercises/18_iterators/iterators4.rs
+++ b/exercises/18_iterators/iterators4.rs
@@ -1,8 +1,3 @@
-// iterators4.rs
-//
-// Execute `rustlings hint iterators4` or use the `hint` watch subcommand for a
-// hint.
-
pub fn factorial(num: u64) -> u64 {
// Complete this function to return the factorial of num
// Do not use:
@@ -12,7 +7,6 @@ pub fn factorial(num: u64) -> u64 {
// - additional variables
// For an extra challenge, don't use:
// - recursion
- // Execute `rustlings hint iterators4` for hints.
}
fn main() {
diff --git a/exercises/18_iterators/iterators5.rs b/exercises/18_iterators/iterators5.rs
index 2604004..4f052d5 100644
--- a/exercises/18_iterators/iterators5.rs
+++ b/exercises/18_iterators/iterators5.rs
@@ -1,5 +1,3 @@
-// iterators5.rs
-//
// Let's define a simple model to track Rustlings exercise progress. Progress
// will be modelled using a hash map. The name of the exercise is the key and
// the progress is the value. Two counting functions were created to count the
@@ -7,9 +5,6 @@
// functionality using iterators. Try not to use imperative loops (for, while).
// Only the two iterator methods (count_iterator and count_collection_iterator)
// need to be modified.
-//
-// Execute `rustlings hint iterators5` or use the `hint` watch subcommand for a
-// hint.
use std::collections::HashMap;