From 06ce7bec7b1b08d226aaf20c189cb4cd0439aaf9 Mon Sep 17 00:00:00 2001 From: rasul Date: Tue, 7 Apr 2020 14:42:53 -0500 Subject: [PATCH] use the From<(Token, Into)> impl --- src/command/dispatch/quit.rs | 3 +-- src/command/set/player/name.rs | 2 +- src/command/set/player/password.rs | 2 +- src/command/set/room/description/delete.rs | 4 ++-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/command/dispatch/quit.rs b/src/command/dispatch/quit.rs index 9df0bef..fa946a2 100644 --- a/src/command/dispatch/quit.rs +++ b/src/command/dispatch/quit.rs @@ -3,11 +3,10 @@ use mio::Token; use crate::command::Command; use crate::database::Db; use crate::queue::SendQueue; -use crate::state::State; impl Command { /// Quit the game pub fn dispatch_quit(&self, _: String, token: Token, _: &mut Db) -> SendQueue { - SendQueue(vec![(token, "Goodbye\n\n".into(), false, Some(State::Quit))].into()) + (token, "Goodbye\n\n").into() } } diff --git a/src/command/set/player/name.rs b/src/command/set/player/name.rs index e52cb37..cbbd657 100644 --- a/src/command/set/player/name.rs +++ b/src/command/set/player/name.rs @@ -12,7 +12,7 @@ impl CommandSetPlayer { let new_name = args.trim(); if new_name.is_empty() { - return SendQueue(vec![(token, "Name can't be empty".into(), true, None)].into()); + return (token, "Name can't be empty").into(); } player.name = new_name.to_string(); diff --git a/src/command/set/player/password.rs b/src/command/set/player/password.rs index 6f3e47f..29476c5 100644 --- a/src/command/set/player/password.rs +++ b/src/command/set/player/password.rs @@ -11,7 +11,7 @@ impl CommandSetPlayer { let mut player = try_option_send_error!(token, db.get_connected_player(token)); if args.is_empty() { - return SendQueue(vec![(token, "Password can't be empty".into(), true, None)].into()); + return (token, "Password can't be empty").into(); } player.password = args; diff --git a/src/command/set/room/description/delete.rs b/src/command/set/room/description/delete.rs index 04bf403..cd5e2f8 100644 --- a/src/command/set/room/description/delete.rs +++ b/src/command/set/room/description/delete.rs @@ -12,7 +12,7 @@ impl CommandSetRoomDescription { pub fn dispatch_delete(&self, args: String, token: Token, db: &mut Db) -> SendQueue { // make sure something was provided if args.is_empty() { - return SendQueue(vec![(token, "Delete which line?".into(), true, None)].into()); + return (token, "Delete which line?").into(); } // try and get the line number @@ -30,7 +30,7 @@ impl CommandSetRoomDescription { // make sure description has enough lines if line_num > room.description.len().into() || line_num <= 0 { - return SendQueue(vec![(token, "Line doeesn't exist".into(), true, None)].into()); + return (token, "Line doesn't exist").into(); } // remove the line and save