Skip to content

Commit

Permalink
parser: remove panicking From<&str> for Whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Kijewski authored and djc committed Aug 1, 2023
1 parent 985eb89 commit 7c3a85d
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions askama_parser/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,18 +699,11 @@ pub enum Whitespace {

impl Whitespace {
fn parse(i: &str) -> IResult<&str, Self> {
alt((char('-'), char('+'), char('~')))(i).map(|(s, r)| (s, Self::from(r)))
}
}

impl From<char> for Whitespace {
fn from(c: char) -> Self {
match c {
'+' => Self::Preserve,
'-' => Self::Suppress,
'~' => Self::Minimize,
_ => panic!("unsupported `Whitespace` conversion"),
}
alt((
value(Self::Preserve, char('+')),
value(Self::Suppress, char('-')),
value(Self::Minimize, char('~')),
))(i)
}
}

Expand Down

0 comments on commit 7c3a85d

Please sign in to comment.