change format! to concat()

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

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

Loading…
Cancel
Save