prefer 'if let' over 'unwrap()'

This commit is contained in:
B. Petersen
2020-11-19 13:36:17 +01:00
parent a29dc514d3
commit e19d2cccfc

View File

@@ -1309,10 +1309,13 @@ fn get_attachment_filename(mail: &mailparse::ParsedMail) -> Result<Option<String
// and things should not be totally bad for other encodings. // and things should not be totally bad for other encodings.
// we can tweak that when we see sth. else really used in the wild nowadays. // we can tweak that when we see sth. else really used in the wild nowadays.
let desired_filename = if let Some(name) = desired_filename { let desired_filename = if let Some(name) = desired_filename {
let name = name.splitn(3, '\'').last().unwrap().to_string(); if let Some(name) = name.splitn(3, '\'').last() {
Some(percent_decode_str(&name).decode_utf8_lossy().to_string()) Some(percent_decode_str(&name).decode_utf8_lossy().to_string())
} else { } else {
None None
}
} else {
None
}; };
// If there is no filename, but part is an attachment, guess filename // If there is no filename, but part is an attachment, guess filename