Use strip_prefix to strip prefix

No need to do it manually.
This commit is contained in:
Hugo Osvaldo Barrera 2023-06-18 17:10:02 +02:00 committed by Kenny Levinsen
parent 4b402a5753
commit 195a811177
1 changed files with 3 additions and 3 deletions

View File

@ -60,9 +60,9 @@ enum LoginResult {
fn login(node: &str, cmd: &mut Option<String>) -> Result<LoginResult, Box<dyn std::error::Error>> {
let username = loop {
let username = prompt_stderr(&format!("{} login: ", node))?;
if username.starts_with('!') {
*cmd = Some(username[1..].to_string());
eprintln!("Login command changed to: {}", &username[1..]);
if let Some(u) = username.strip_prefix('!') {
*cmd = Some(u.to_string());
eprintln!("Login command changed to: {u}");
continue;
}
break username;