diff options
author | René Kijewski <rene.kijewski@fu-berlin.de> | 2023-08-01 04:33:36 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2023-08-01 07:06:30 +0200 |
commit | 7c3a85de4fe8851bbff7c477237ed88954b9f9c5 (patch) | |
tree | 652826366d453a3b03b93ef746674c2356a601ef /askama_parser/src/node.rs | |
parent | 985eb8955f36e909d18f7ea6eaf4c748e7afd17a (diff) | |
download | askama-7c3a85de4fe8851bbff7c477237ed88954b9f9c5.tar.gz askama-7c3a85de4fe8851bbff7c477237ed88954b9f9c5.tar.bz2 askama-7c3a85de4fe8851bbff7c477237ed88954b9f9c5.zip |
parser: remove panicking `From<&str> for Whitespace`
Diffstat (limited to 'askama_parser/src/node.rs')
-rw-r--r-- | askama_parser/src/node.rs | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/askama_parser/src/node.rs b/askama_parser/src/node.rs index b9685e8..4a0fa30 100644 --- a/askama_parser/src/node.rs +++ b/askama_parser/src/node.rs @@ -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) } } |