diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2021-10-05 10:12:03 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2021-10-05 10:47:53 +0200 |
commit | 5c4d169a41969f0823ac549b72c8a7af8ecbea9f (patch) | |
tree | 1fa75900a2439b6025ba3f8fc19bf1a24e37b2a4 /askama_shared | |
parent | b93ce466cee51f879edd346d05c0faa4845ee1cc (diff) | |
download | askama-5c4d169a41969f0823ac549b72c8a7af8ecbea9f.tar.gz askama-5c4d169a41969f0823ac549b72c8a7af8ecbea9f.tar.bz2 askama-5c4d169a41969f0823ac549b72c8a7af8ecbea9f.zip |
Fix suggestions from nightly clippy
Diffstat (limited to '')
-rw-r--r-- | askama_shared/src/parser.rs | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/askama_shared/src/parser.rs b/askama_shared/src/parser.rs index eba4370..995fc19 100644 --- a/askama_shared/src/parser.rs +++ b/askama_shared/src/parser.rs @@ -272,21 +272,19 @@ fn num_lit(i: &[u8]) -> IResult<&[u8], &str> { } fn expr_num_lit(i: &[u8]) -> IResult<&[u8], Expr<'_>> { - map(num_lit, |s| Expr::NumLit(s))(i) + map(num_lit, Expr::NumLit)(i) } fn expr_array_lit(i: &[u8]) -> IResult<&[u8], Expr<'_>> { delimited( ws(tag("[")), - map(separated_list1(ws(tag(",")), expr_any), |arr| { - Expr::Array(arr) - }), + map(separated_list1(ws(tag(",")), expr_any), Expr::Array), ws(tag("]")), )(i) } fn variant_num_lit(i: &[u8]) -> IResult<&[u8], Target<'_>> { - map(num_lit, |s| Target::NumLit(s))(i) + map(num_lit, Target::NumLit)(i) } fn str_lit(i: &[u8]) -> IResult<&[u8], &str> { @@ -301,11 +299,11 @@ fn str_lit(i: &[u8]) -> IResult<&[u8], &str> { } fn expr_str_lit(i: &[u8]) -> IResult<&[u8], Expr<'_>> { - map(str_lit, |s| Expr::StrLit(s))(i) + map(str_lit, Expr::StrLit)(i) } fn variant_str_lit(i: &[u8]) -> IResult<&[u8], Target<'_>> { - map(str_lit, |s| Target::StrLit(s))(i) + map(str_lit, Target::StrLit)(i) } fn char_lit(i: &[u8]) -> IResult<&[u8], &str> { @@ -320,15 +318,15 @@ fn char_lit(i: &[u8]) -> IResult<&[u8], &str> { } fn expr_char_lit(i: &[u8]) -> IResult<&[u8], Expr<'_>> { - map(char_lit, |s| Expr::CharLit(s))(i) + map(char_lit, Expr::CharLit)(i) } fn variant_char_lit(i: &[u8]) -> IResult<&[u8], Target<'_>> { - map(char_lit, |s| Target::CharLit(s))(i) + map(char_lit, Target::CharLit)(i) } fn expr_var(i: &[u8]) -> IResult<&[u8], Expr<'_>> { - map(identifier, |s| Expr::Var(s))(i) + map(identifier, Expr::Var)(i) } fn expr_var_call(i: &[u8]) -> IResult<&[u8], Expr<'_>> { @@ -1039,9 +1037,7 @@ fn block_macro<'a>(i: &'a [u8], s: &State<'_>) -> IResult<&'a [u8], Node<'a>> { )); let (i, (pws1, _, (name, params, nws1, _, (contents, (_, pws2, _, nws2))))) = p(i)?; - if name == "super" { - panic!("invalid macro name 'super'"); - } + assert_ne!(name, "super", "invalid macro name 'super'"); Ok(( i, |