Skip to content

Commit 77d5e83

Browse files
authored
Merge pull request #15 from Rimpampa/main
Remove possible panic on remove_prefix
2 parents 4373911 + fa00006 commit 77d5e83

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/parse.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ fn remove_prefix(data: &'_ str) -> Result<&'_ str, ParseError> {
7575
}
7676

7777
// check HC1: header
78-
if &data[0..4] != "HC1:" {
79-
return Err(ParseError::InvalidPrefix(String::from(&data[0..3])));
78+
if !data.starts_with("HC1:") {
79+
return Err(ParseError::InvalidPrefix(data.chars().take(4).collect()));
8080
}
8181

8282
Ok(&data[4..])

0 commit comments

Comments
 (0)