Skip to content

Commit 6b0f805

Browse files
committed
Improved decoder results.
1 parent bfaeeeb commit 6b0f805

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/parsers/message.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,21 @@ fn result_to_string<'x>(
4747
data: &'x [u8],
4848
content_type: Option<&ContentType>,
4949
) -> Cow<'x, str> {
50-
let charset_decoder = content_type.and_then(|ct| {
51-
ct.get_attribute("charset").and_then(|c| get_charset_decoder(c.as_bytes()))
52-
});
53-
54-
match (result, charset_decoder) {
50+
match (
51+
result,
52+
content_type.and_then(|ct| {
53+
ct.get_attribute("charset")
54+
.and_then(|c| get_charset_decoder(c.as_bytes()))
55+
}),
56+
) {
5557
(DecodeResult::Owned(vec), Some(charset_decoder)) => charset_decoder(&vec).into(),
5658
(DecodeResult::Owned(vec), None) => String::from_utf8(vec)
5759
.unwrap_or_else(|e| String::from_utf8_lossy(e.as_bytes()).into_owned())
5860
.into(),
5961
(DecodeResult::Borrowed((from, to)), Some(charset_decoder)) => {
6062
charset_decoder(&data[from..to]).into()
6163
}
62-
(DecodeResult::Borrowed((from, to)), None) => {
63-
String::from_utf8_lossy(&data[from..to])
64-
}
64+
(DecodeResult::Borrowed((from, to)), None) => String::from_utf8_lossy(&data[from..to]),
6565
(DecodeResult::Empty, _) => "\n".to_string().into(),
6666
}
6767
}

0 commit comments

Comments
 (0)