Browse Source

initial commit

master
Jim Infield 3 years ago
commit
d5c6cce35d
  1. 2
      .gitignore
  2. 8
      Cargo.toml
  3. 17
      src/lib.rs

2
.gitignore

@ -0,0 +1,2 @@
/target
Cargo.lock

8
Cargo.toml

@ -0,0 +1,8 @@
[package]
name = "open_or_senior"
version = "0.1.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

17
src/lib.rs

@ -0,0 +1,17 @@
#![allow(unused)]
fn open_or_senior(data: Vec<(i32, i32)>) -> Vec<String> {
data.iter()
.map(|(age, hc)| if hc > &7 && age > &54 { "Senior".into() } else { "Open".into() })
.collect::<Vec<String>>()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn returns_expected() {
assert_eq!(open_or_senior(vec![(45, 12), (55,21), (19, -2), (104, 20)]), vec!["Open", "Senior", "Open", "Senior"]);
assert_eq!(open_or_senior(vec![(3, 12), (55,1), (91, -2), (54, 23)]), vec!["Open", "Open", "Open", "Open"]);
}
}
Loading…
Cancel
Save