diff --git a/src/population.rs b/src/population.rs index d508b6f..f746fa4 100644 --- a/src/population.rs +++ b/src/population.rs @@ -30,7 +30,14 @@ impl Population { height: i32, plague: Disease, ) -> Self { - let mut the_humans: Vec = vec![Human{x: 0, y: 0, present_state: State::Normal}; (width * height) as usize]; + let mut the_humans: Vec = vec![ + Human { + x: 0, + y: 0, + present_state: State::Normal + }; + (width * height) as usize + ]; for x in 0..width { for y in 0..height { let idx = human_idx(x, y, width); @@ -116,7 +123,7 @@ impl Population { stats[0] += 1; } State::Infected => { - people_to_check.push(Point{ x: h.x, y: h.y }); + people_to_check.push(Point { x: h.x, y: h.y }); stats[1] += 1; } State::Immune => { @@ -345,7 +352,7 @@ mod tests { let mut stats: Stats; for _ in 0..10 { - humans.push(Human{ + humans.push(Human { present_state: State::Normal, x: 0, y: 0, @@ -388,7 +395,6 @@ mod tests { assert_eq!(population.humans[idx].y, h.y, "coordinates should match"); } assert_eq!(population.humans.len(), (width * height) as usize); - } #[test] @@ -505,15 +511,51 @@ mod tests { // start with normal population population.humans = vec![ - Human{present_state: State::Normal, x: 0, y: 0}, - Human{present_state: State::Normal, x: 1, y: 0}, - Human{present_state: State::Normal, x: 2, y: 0}, - Human{present_state: State::Normal, x: 0, y: 1}, - Human{present_state: State::Infected, x: 1, y: 1}, - Human{present_state: State::Normal, x: 2, y: 1}, - Human{present_state: State::Normal, x: 0, y: 2}, - Human{present_state: State::Normal, x: 1, y: 2}, - Human{present_state: State::Normal, x: 2, y: 2}, + Human { + present_state: State::Normal, + x: 0, + y: 0, + }, + Human { + present_state: State::Normal, + x: 1, + y: 0, + }, + Human { + present_state: State::Normal, + x: 2, + y: 0, + }, + Human { + present_state: State::Normal, + x: 0, + y: 1, + }, + Human { + present_state: State::Infected, + x: 1, + y: 1, + }, + Human { + present_state: State::Normal, + x: 2, + y: 1, + }, + Human { + present_state: State::Normal, + x: 0, + y: 2, + }, + Human { + present_state: State::Normal, + x: 1, + y: 2, + }, + Human { + present_state: State::Normal, + x: 2, + y: 2, + }, ]; stats = humans_stats(&population.humans); println!("stats after init: {:?}", stats); @@ -550,15 +592,51 @@ mod tests { // start with normal population population.humans = vec![ - Human{present_state: State::Normal, x: 0, y: 0}, - Human{present_state: State::Normal, x: 1, y: 0}, - Human{present_state: State::Normal, x: 2, y: 0}, - Human{present_state: State::Normal, x: 0, y: 1}, - Human{present_state: State::Infected, x: 1, y: 1}, - Human{present_state: State::Normal, x: 2, y: 1}, - Human{present_state: State::Normal, x: 0, y: 2}, - Human{present_state: State::Normal, x: 1, y: 2}, - Human{present_state: State::Normal, x: 2, y: 2}, + Human { + present_state: State::Normal, + x: 0, + y: 0, + }, + Human { + present_state: State::Normal, + x: 1, + y: 0, + }, + Human { + present_state: State::Normal, + x: 2, + y: 0, + }, + Human { + present_state: State::Normal, + x: 0, + y: 1, + }, + Human { + present_state: State::Infected, + x: 1, + y: 1, + }, + Human { + present_state: State::Normal, + x: 2, + y: 1, + }, + Human { + present_state: State::Normal, + x: 0, + y: 2, + }, + Human { + present_state: State::Normal, + x: 1, + y: 2, + }, + Human { + present_state: State::Normal, + x: 2, + y: 2, + }, ]; stats = humans_stats(&population.humans); println!("stats after init: {:?}", stats);