From 4ff6d69534f36a3ccd0c54eb8e51403a904481f3 Mon Sep 17 00:00:00 2001
From: aj <andrewjpack@gmail.com>
Date: Sat, 10 Oct 2020 17:00:59 +0100
Subject: [PATCH] added iterator and tests

---
 src/collections.rs    |  4 ----
 src/iterate.rs        | 25 +++++++++++++++++++++++++
 src/main.rs           | 12 +++++++++++-
 tests/add_tests.rs    |  7 +++++++
 tests/scaffold/mod.rs |  4 ++++
 5 files changed, 47 insertions(+), 5 deletions(-)
 delete mode 100644 src/collections.rs
 create mode 100644 src/iterate.rs
 create mode 100644 tests/add_tests.rs
 create mode 100644 tests/scaffold/mod.rs

diff --git a/src/collections.rs b/src/collections.rs
deleted file mode 100644
index a79f86f..0000000
--- a/src/collections.rs
+++ /dev/null
@@ -1,4 +0,0 @@
-
-fn hello_world(){
-    
-}
\ No newline at end of file
diff --git a/src/iterate.rs b/src/iterate.rs
new file mode 100644
index 0000000..6555c3a
--- /dev/null
+++ b/src/iterate.rs
@@ -0,0 +1,25 @@
+
+mod iterate {
+    struct Counter {
+        count: u32,
+    }
+    
+    impl Counter {
+        fn new() -> Counter {
+            Counter { count: 0 }
+        }
+    }
+
+    impl Iterator for Counter {
+        type Item = u32;
+    
+        fn next(&mut self) -> Option<Self::Item> {
+            if self.count < 5 {
+                self.count += 1;
+                Some(self.count)
+            } else {
+                None
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/main.rs b/src/main.rs
index cf7d1d7..eb5e2ab 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -2,7 +2,7 @@ use std::io;
 use std::cmp::Ordering;
 use rand::Rng;
 
-mod collections;
+mod iterate;
 
 fn main() {
     basics();
@@ -178,4 +178,14 @@ fn nullables() {
     let _some_string = Some("a string");
 
     let _absent_number: Option<i32> = None;
+}
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    #[test]
+    fn test1() {
+        assert_eq!(2, 1 + 1);
+    }
 }
\ No newline at end of file
diff --git a/tests/add_tests.rs b/tests/add_tests.rs
new file mode 100644
index 0000000..1cd5940
--- /dev/null
+++ b/tests/add_tests.rs
@@ -0,0 +1,7 @@
+mod scaffold;
+
+#[test]
+fn add_test_1() {
+    scaffold::setup();
+    assert_eq!(4, 2 + 2);
+}
\ No newline at end of file
diff --git a/tests/scaffold/mod.rs b/tests/scaffold/mod.rs
new file mode 100644
index 0000000..251919d
--- /dev/null
+++ b/tests/scaffold/mod.rs
@@ -0,0 +1,4 @@
+
+pub fn setup() {
+    println!("During test");
+}
\ No newline at end of file