use the From<(Token, Into<String>)> impl

master
rasul 5 years ago
parent 24c6c01da7
commit 06ce7bec7b

@ -3,11 +3,10 @@ use mio::Token;
use crate::command::Command; use crate::command::Command;
use crate::database::Db; use crate::database::Db;
use crate::queue::SendQueue; use crate::queue::SendQueue;
use crate::state::State;
impl Command { impl Command {
/// Quit the game /// Quit the game
pub fn dispatch_quit(&self, _: String, token: Token, _: &mut Db) -> SendQueue { 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()
} }
} }

@ -12,7 +12,7 @@ impl CommandSetPlayer {
let new_name = args.trim(); let new_name = args.trim();
if new_name.is_empty() { 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(); player.name = new_name.to_string();

@ -11,7 +11,7 @@ impl CommandSetPlayer {
let mut player = try_option_send_error!(token, db.get_connected_player(token)); let mut player = try_option_send_error!(token, db.get_connected_player(token));
if args.is_empty() { 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; player.password = args;

@ -12,7 +12,7 @@ impl CommandSetRoomDescription {
pub fn dispatch_delete(&self, args: String, token: Token, db: &mut Db) -> SendQueue { pub fn dispatch_delete(&self, args: String, token: Token, db: &mut Db) -> SendQueue {
// make sure something was provided // make sure something was provided
if args.is_empty() { 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 // try and get the line number
@ -30,7 +30,7 @@ impl CommandSetRoomDescription {
// make sure description has enough lines // make sure description has enough lines
if line_num > room.description.len().into() || line_num <= 0 { 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 // remove the line and save

Loading…
Cancel
Save