skip_forward_header: get rid of indexing with subslice patterns

This commit is contained in:
Alexander Krotov
2020-03-28 03:11:24 +03:00
committed by Alexander Krotov
parent 1c21d4f356
commit d997bbc081

View File

@@ -67,14 +67,13 @@ pub fn simplify(mut input: String, is_chat_message: bool) -> (String, bool) {
/// Returns message body lines and a boolean indicating whether /// Returns message body lines and a boolean indicating whether
/// a message is forwarded or not. /// a message is forwarded or not.
fn skip_forward_header<'a>(lines: &'a [&str]) -> (&'a [&'a str], bool) { fn skip_forward_header<'a>(lines: &'a [&str]) -> (&'a [&'a str], bool) {
if lines.len() >= 3 match lines {
&& lines[0] == "---------- Forwarded message ----------" ["---------- Forwarded message ----------", first_line, "", rest @ ..]
&& lines[1].starts_with("From: ") if first_line.starts_with("From: ") =>
&& lines[2].is_empty() {
{ (rest, true)
(&lines[3..], true) }
} else { _ => (lines, false),
(lines, false)
} }
} }