diff options
author | tom barrett <spalf0@gmail.com> | 2018-04-11 09:00:27 -0500 |
---|---|---|
committer | tom barrett <spalf0@gmail.com> | 2018-04-11 09:00:27 -0500 |
commit | ab797e7f30e5e8913faf73516346129b9a620550 (patch) | |
tree | 17ac1c1ee27d2d82c32772c24a5a246b61a73756 /src/bin | |
parent | f3955f07478ace406422ebfe71abab359fe4c229 (diff) |
-moved over to hashmap
Diffstat (limited to 'src/bin')
-rw-r--r-- | src/bin/server.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/bin/server.rs b/src/bin/server.rs index 16186d7..f7aaffe 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -1,6 +1,7 @@ use std::thread::sleep; use std::time::Duration; use std::net::TcpListener; +use std::collections::HashMap; extern crate space; use space::mass::Mass; @@ -8,11 +9,11 @@ use space::astroid::Astroid; use space::connection::Connection; -fn populate() -> Vec<Box<Mass>> { - let mut masses : Vec<Box<Mass>> = Vec::new(); +fn populate() -> HashMap<String, Box<Mass>> { + let mut masses : HashMap<String, Box<Mass>> = HashMap::new(); for _ in 0..10 { - masses.push(Box::new(Astroid::new())); + masses.insert("zz".to_string(), Box::new(Astroid::new())); } masses @@ -34,7 +35,7 @@ fn main() { } connections.retain(|connection| connection.open); - for mass in masses.iter_mut() { + for mass in masses.values_mut() { mass.process(); } |