change format! to concat()

master
rasul 4 years ago
parent cea795b99d
commit 321f09c910

@ -64,23 +64,32 @@ pub fn player_name<S: Into<String>>(name: S) -> PlayerCheck {
let mut err_vec = Vec::<String>::new(); let mut err_vec = Vec::<String>::new();
if name.len() < NAME_MIN.with(|n| *n.borrow()) { if name.len() < NAME_MIN.with(|n| *n.borrow()) {
err_vec.push(format!( err_vec.push(
"{} character minimum", [
NAME_MIN.with(|n| *n.borrow()) &NAME_MIN.with(|n| *n.borrow()).to_string(),
)); " character minimum",
]
.concat(),
);
} else if name.len() > NAME_MAX.with(|n| *n.borrow()) { } else if name.len() > NAME_MAX.with(|n| *n.borrow()) {
err_vec.push(format!( err_vec.push(
"{} character maximum", [
NAME_MAX.with(|n| *n.borrow()) &NAME_MAX.with(|n| *n.borrow()).to_string(),
)); " character maximum"
]
.concat()
);
} }
for c in name.chars() { for c in name.chars() {
if !NAME_CHARS.with(|n| *n.borrow()).contains(&c.to_string()) { if !NAME_CHARS.with(|n| *n.borrow()).contains(&c.to_string()) {
err_vec.push(format!( err_vec.push(
"Allowed characters are: {}", [
NAME_CHARS.with(|n| *n.borrow()) "Allowed characters are: ",
)); &NAME_CHARS.with(|n| *n.borrow())
]
.concat()
);
break; break;
} }
} }
@ -98,23 +107,32 @@ pub fn player_password<S: Into<String>>(password: S) -> PlayerCheck {
let mut err_vec = Vec::<String>::new(); let mut err_vec = Vec::<String>::new();
if password.len() < PASS_MIN.with(|p| *p.borrow()) { if password.len() < PASS_MIN.with(|p| *p.borrow()) {
err_vec.push(format!( err_vec.push(
"{} character minimum", [
PASS_MIN.with(|p| *p.borrow()) &PASS_MIN.with(|p| *p.borrow()).to_string(),
)); " character minimum"
]
.concat()
);
} else if password.len() > PASS_MAX.with(|p| *p.borrow()) { } else if password.len() > PASS_MAX.with(|p| *p.borrow()) {
err_vec.push(format!( err_vec.push(
"{} character maximum", [
PASS_MAX.with(|p| *p.borrow()) &PASS_MAX.with(|p| *p.borrow()).to_string(),
)); " character maximum"
]
.concat()
);
} }
for c in password.chars() { for c in password.chars() {
if !PASS_CHARS.with(|p| *p.borrow()).contains(&c.to_string()) { if !PASS_CHARS.with(|p| *p.borrow()).contains(&c.to_string()) {
err_vec.push(format!( err_vec.push(
"Allowed characters are: {}", [
PASS_CHARS.with(|p| *p.borrow()) "Allowed characters are: ",
)); &PASS_CHARS.with(|p| *p.borrow()).to_string()
]
.concat()
);
break; break;
} }
} }

@ -19,9 +19,9 @@ impl Command {
send_queue.push( send_queue.push(
neighbor_token, neighbor_token,
if neighbor_token == token { if neighbor_token == token {
format!("You say, \"{}\"\n", args) ["You say, \"", &args, "\"\n"].concat()
} else { } else {
format!("{} says, \"{}\"\n", player.name, args) [&player.name, " says, \"", &args, "\"\n"].concat()
}, },
true, true,
None, None,

Loading…
Cancel
Save