-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add exercise-{solutions|templates}/iterators
- Loading branch information
Showing
6 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "iterators" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//ignore everything that is not a number | ||
1 | ||
2 | ||
3 | ||
4 | ||
five | ||
6 | ||
7 | ||
∞ | ||
9 | ||
X |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#![allow(unused_imports)] | ||
use std::io::{BufReader}; | ||
use std::fs::File; | ||
use std::error::Error; | ||
|
||
fn main() -> Result<(), Box<dyn Error>> { | ||
use crate::*; | ||
let f = File::open("numbers.txt")?; | ||
let mut reader = BufReader::new(f); | ||
let sum_of_odd_numbers: i32 = todo!("use reader.lines() and Iterator methods"); | ||
|
||
assert_eq!(sum_of_odd_numbers, 20); | ||
Ok(()) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "iterators" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//ignore everything that is not a number | ||
1 | ||
2 | ||
3 | ||
4 | ||
five | ||
6 | ||
7 | ||
∞ | ||
9 | ||
X |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#![allow(unused_imports)] | ||
use std::io::BufReader; | ||
use std::fs::File; | ||
use std::error::Error; | ||
|
||
#[test] | ||
fn iterator_test() -> Result<(), Box<dyn Error>> { | ||
use crate::*; | ||
let f = File::open("numbers.txt")?; | ||
let mut reader = BufReader::new(f); | ||
|
||
// Write your iterator chain here | ||
let sum_of_odd_numbers: i32 = todo!("use reader.lines() and Iterator methods"); | ||
|
||
assert_eq!(sum_of_odd_numbers, 20); | ||
Ok(()) | ||
} | ||
|