diff options
author | tom barrett <spalf0@gmail.com> | 2018-02-22 04:32:51 -0600 |
---|---|---|
committer | tom barrett <spalf0@gmail.com> | 2018-02-22 04:32:51 -0600 |
commit | c8d308a566c9e3e5be85e0e67082a06c3420a72b (patch) | |
tree | dbbd0ce6581a60a44b8dc978abc435829d874e0d /src/bin | |
parent | 763653a32e62134a7e394c349d742636b0662a94 (diff) |
-got now a trait which resembles polymorphism for new objects
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 7c6a63e..d2923d8 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -3,23 +3,24 @@ use std::time::Duration; use std::net::TcpListener; extern crate space; +use space::mass::Mass; use space::connection::Connection; fn main() { let listener = TcpListener::bind("localhost:6000").unwrap(); listener.set_nonblocking(true).unwrap(); - let mut ships = Vec::new(); + let mut masses : Vec<Box<Mass>>= Vec::new(); let mut connections = Vec::new(); for stream in listener.incoming() { match stream { - Ok(stream) => connections.push(Connection::new(stream, &mut ships)), + Ok(stream) => connections.push(Connection::new(stream, &mut masses)), _ => { for i in 0..connections.len() { - connections[i].process(&mut ships); + connections[i].process(&mut masses); } - connections.retain(|connection| connection.open ); + connections.retain(|connection| connection.open); sleep(Duration::from_millis(100)); } |