--- a/gameServer2/Cargo.toml Fri Nov 30 17:09:08 2018 +0100
+++ b/gameServer2/Cargo.toml Fri Nov 30 22:37:29 2018 +0300
@@ -15,7 +15,7 @@
slab = "0.4"
netbuf = "0.4"
nom = "4.1"
-env_logger = "0.5"
+env_logger = "0.6"
log = "0.4"
base64 = "0.10"
bitflags = "1.0"
--- a/gameServer2/src/protocol/messages.rs Fri Nov 30 17:09:08 2018 +0100
+++ b/gameServer2/src/protocol/messages.rs Fri Nov 30 22:37:29 2018 +0300
@@ -253,7 +253,7 @@
}
fn construct_message(header: &[&str], msg: &[String]) -> String {
- let mut v: Vec<_> = header.iter().map(|s| *s).collect();
+ let mut v: Vec<_> = header.iter().cloned().collect();
v.extend(msg.iter().map(|s| &s[..]));
v.push("\n");
v.join("\n")
--- a/gameServer2/src/protocol/parser.rs Fri Nov 30 17:09:08 2018 +0100
+++ b/gameServer2/src/protocol/parser.rs Fri Nov 30 22:37:29 2018 +0300
@@ -200,7 +200,7 @@
| do_parse!(tag!("SCHEME") >> eol >>
name: a_line >>
values: opt!(preceded!(eol, separated_list!(eol, a_line))) >>
- (GameCfg::Scheme(name, values.unwrap_or(Vec::new()))))
+ (GameCfg::Scheme(name, values.unwrap_or_default())))
| do_parse!(tag!("FEATURE_SIZE") >> eol >>
value: u32_line >>
(GameCfg::FeatureSize(value)))
--- a/gameServer2/src/server/actions.rs Fri Nov 30 17:09:08 2018 +0100
+++ b/gameServer2/src/server/actions.rs Fri Nov 30 22:37:29 2018 +0300
@@ -339,7 +339,7 @@
if let Some(r) = server.room(client_id) {
let mut result = None;
if let Some(ref mut voting) = r.voting {
- if is_forced || voting.votes.iter().find(|(id, _)| client_id == *id).is_none() {
+ if is_forced || voting.votes.iter().all(|(id, _)| client_id != *id) {
actions.push(server_chat("Your vote has been counted.".to_string())
.send_self().action());
voting.votes.push((client_id, vote));
--- a/gameServer2/src/server/room.rs Fri Nov 30 17:09:08 2018 +0100
+++ b/gameServer2/src/server/room.rs Fri Nov 30 22:37:29 2018 +0300
@@ -228,7 +228,7 @@
pub fn find_team<F>(&self, f: F) -> Option<&TeamInfo>
where F: Fn(&TeamInfo) -> bool {
- self.teams.iter().map(|(_, t)| t).find(|t| f(*t))
+ self.teams.iter().find_map(|(_, t)| Some(t).filter(|t| f(&t)))
}
pub fn client_teams(&self, client_id: ClientId) -> impl Iterator<Item = &TeamInfo> {
--- a/gameServer2/src/server/server.rs Fri Nov 30 17:09:08 2018 +0100
+++ b/gameServer2/src/server/server.rs Fri Nov 30 22:37:29 2018 +0300
@@ -107,19 +107,19 @@
}
pub fn find_room(&self, name: &str) -> Option<&HWRoom> {
- self.rooms.iter().find(|(_, r)| r.name == name).map(|(_, r)| r)
+ self.rooms.iter().find_map(|(_, r)| Some(r).filter(|r| r.name == name))
}
pub fn find_room_mut(&mut self, name: &str) -> Option<&mut HWRoom> {
- self.rooms.iter_mut().find(|(_, r)| r.name == name).map(|(_, r)| r)
+ self.rooms.iter_mut().find_map(|(_, r)| Some(r).filter(|r| r.name == name))
}
pub fn find_client(&self, nick: &str) -> Option<&HWClient> {
- self.clients.iter().find(|(_, c)| c.nick == nick).map(|(_, c)| c)
+ self.clients.iter().find_map(|(_, c)| Some(c).filter(|c| c.nick == nick))
}
pub fn find_client_mut(&mut self, nick: &str) -> Option<&mut HWClient> {
- self.clients.iter_mut().find(|(_, c)| c.nick == nick).map(|(_, c)| c)
+ self.clients.iter_mut().find_map(|(_, c)| Some(c).filter(|c| c.nick == nick))
}
pub fn select_clients<F>(&self, f: F) -> Vec<ClientId>
--- a/rust/vec2d/src/lib.rs Fri Nov 30 17:09:08 2018 +0100
+++ b/rust/vec2d/src/lib.rs Fri Nov 30 22:37:29 2018 +0300
@@ -87,13 +87,13 @@
#[inline]
pub fn rows(&self) -> impl DoubleEndedIterator<Item = &[T]> {
- self.data.chunks(self.width())
+ self.data.chunks_exact(self.width())
}
#[inline]
pub fn rows_mut(&mut self) -> impl DoubleEndedIterator<Item = &mut [T]> {
let width = self.width();
- self.data.chunks_mut(width)
+ self.data.chunks_exact_mut(width)
}
}