Skip to content

Commit

Permalink
Refactor header line condition to avoid None unwrap
Browse files Browse the repository at this point in the history
If the test source file doesn't contain any headers, or
that are not added till now then the header value
will be None and becomes panic

Signed-off-by: Muhammad Mahad <[email protected]>
  • Loading branch information
MahadMuhammad committed Aug 25, 2024
1 parent e561a01 commit 8a33157
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ pub fn parse_additional_options(code: &str) -> Vec<HeaderLine> {
continue;
}
if is_header_line(line) {
headers.push(add_additional_options(line, line_number).unwrap());
if let Some(header_info) = add_additional_options(line, line_number) {
headers.push(header_info);
}
}
}
headers
Expand Down

0 comments on commit 8a33157

Please sign in to comment.