Skip to content

Commit

Permalink
Refactor to avoid use of unwrap
Browse files Browse the repository at this point in the history
  • Loading branch information
KateMorley committed Oct 14, 2023
1 parent 09c702a commit c34725d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions argh_derive/src/parse_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,13 @@ fn unescape_doc(s: String) -> String {

let mut characters = s.chars().peekable();
while let Some(mut character) = characters.next() {
if character == '\\' && characters.peek().map_or(false, |next| next.is_ascii_punctuation())
{
character = characters.next().unwrap()
if character == '\\' {
if let Some(next_character) = characters.peek() {
if next_character.is_ascii_punctuation() {
character = *next_character;
characters.next();
}
}
}

// Braces must be escaped as this string will be used as a format string
Expand Down

0 comments on commit c34725d

Please sign in to comment.