From 4b2fdd1eb303ccc65b916508fcaa8ed90c244fe9 Mon Sep 17 00:00:00 2001 From: Rene Luria Date: Tue, 3 May 2022 12:58:32 +0200 Subject: [PATCH] Use new() impl for humans --- src/human.rs | 15 ++++++++------- src/population.rs | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/human.rs b/src/human.rs index a6ba1ee..f289ad7 100644 --- a/src/human.rs +++ b/src/human.rs @@ -15,13 +15,14 @@ pub struct Human { pub y : i32, } impl Human{ - // pub fn new(state : State, pos_x :i32, pos_y :i32) -> Self{ - // Self{ - // present_state : state, - // x : pos_x, - // y : pos_y - // } - // } + // humans with state "Normal" + pub fn new(pos_x :i32, pos_y :i32) -> Self{ + Self{ + present_state : State::Normal, + x : pos_x, + y : pos_y + } + } // pub fn new_empty() -> Self{ // Self{ // present_state:State::Normal, diff --git a/src/population.rs b/src/population.rs index f4232a1..ff27018 100644 --- a/src/population.rs +++ b/src/population.rs @@ -26,7 +26,7 @@ impl Population{ let mut the_humans: Vec = Vec::with_capacity((width*height) as usize); for x in 0..width{ for y in 0..height{ - the_humans.push(Human{present_state: State::Normal, x: x, y: y}); + the_humans.push(Human::new(x, y)); } } Self{