Skip to content

Commit

Permalink
fix clippy warning
Browse files Browse the repository at this point in the history
  • Loading branch information
zh-jq-b committed May 16, 2024
1 parent 0f0bcb0 commit 03845c7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
14 changes: 8 additions & 6 deletions lib/g3-smtp-proto/src/command/mail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,19 @@ impl MailParam {
let msg = str::from_utf8(msg).map_err(CommandLineError::InvalidUtf8Command)?;

let mut iter = msg.split_ascii_whitespace();
let s = iter.next().ok_or_else(|| {
CommandLineError::InvalidCommandParam("MAIL", "no reverse path present")
})?;
let s = iter.next().ok_or(CommandLineError::InvalidCommandParam(
"MAIL",
"no reverse path present",
))?;

let reverse_path = s
.to_lowercase()
.strip_prefix("from:")
.map(|s| s.to_string())
.ok_or_else(|| {
CommandLineError::InvalidCommandParam("MAIL", "invalid reverse path prefix")
})?;
.ok_or(CommandLineError::InvalidCommandParam(
"MAIL",
"invalid reverse path prefix",
))?;

Ok(MailParam { reverse_path })
}
Expand Down
14 changes: 8 additions & 6 deletions lib/g3-smtp-proto/src/command/recipient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,19 @@ impl RecipientParam {
let msg = str::from_utf8(msg).map_err(CommandLineError::InvalidUtf8Command)?;

let mut iter = msg.split_ascii_whitespace();
let s = iter.next().ok_or_else(|| {
CommandLineError::InvalidCommandParam("RCPT", "no forward path present")
})?;
let s = iter.next().ok_or(CommandLineError::InvalidCommandParam(
"RCPT",
"no forward path present",
))?;

let forward_path = s
.to_lowercase()
.strip_prefix("to:")
.map(|s| s.to_string())
.ok_or_else(|| {
CommandLineError::InvalidCommandParam("RCPT", "invalid forward path prefix")
})?;
.ok_or(CommandLineError::InvalidCommandParam(
"RCPT",
"invalid forward path prefix",
))?;

Ok(RecipientParam { forward_path })
}
Expand Down

0 comments on commit 03845c7

Please sign in to comment.