From dbccb345820aa1d0cbd34ffbca04a1f25b1cd9a7 Mon Sep 17 00:00:00 2001 From: sxv20_ Date: Tue, 16 Apr 2019 17:34:41 +0100 Subject: [PATCH] replace if-let with match Former-commit-id: ed39cbb1ccc69302cb65822ad4a4cfecd2bd8f86 --- server/src/cmd.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/server/src/cmd.rs b/server/src/cmd.rs index b090f38fc0..529b09f0a8 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -4,12 +4,12 @@ use crate::Server; use common::{comp, msg::ServerMsg}; -use specs::{Entity as EcsEntity, join::Join}; +use specs::{join::Join, Entity as EcsEntity}; use vek::*; -use scan_fmt::scan_fmt; -use lazy_static::lazy_static; +use lazy_static::lazy_static; +use scan_fmt::scan_fmt; /// Struct representing a command that a user can run from server chat pub struct ChatCommand { /// The keyword used to invoke the command, omitting the leading '/' @@ -88,18 +88,17 @@ fn handle_jump(server: &mut Server, entity: EcsEntity, args: String, action: &Ch let (opt_x, opt_y, opt_z) = scan_fmt!(&args, action.arg_fmt, f32, f32, f32); match (opt_x, opt_y, opt_z) { (Some(x), Some(y), Some(z)) => { - if let Some(current_pos) = server + match server .state .read_component_cloned::(entity) { - server + Some(current_pos) => server .state - .write_component(entity, comp::phys::Pos(current_pos.0 + Vec3::new(x, y, z))) - } else { - server.clients.notify( + .write_component(entity, comp::phys::Pos(current_pos.0 + Vec3::new(x, y, z))), + None => server.clients.notify( entity, ServerMsg::Chat(String::from("Command 'jump' invalid in current state")), - ) + ), } } _ => server