diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2023-09-28 15:20:04 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2023-09-28 17:28:26 +0200 |
commit | 57181752917c67a007c86fdbe133d2c64db7c749 (patch) | |
tree | 5a05699619b35c6a580d1cbd7abf7fdcc8367851 /askama_parser/src | |
parent | 5ab8813fe29cfbc034b6f99fc36064dcd1a5bd3e (diff) | |
download | askama-57181752917c67a007c86fdbe133d2c64db7c749.tar.gz askama-57181752917c67a007c86fdbe133d2c64db7c749.tar.bz2 askama-57181752917c67a007c86fdbe133d2c64db7c749.zip |
Move Level into the crate root
Diffstat (limited to '')
-rw-r--r-- | askama_parser/src/expr.rs | 17 | ||||
-rw-r--r-- | askama_parser/src/lib.rs | 15 | ||||
-rw-r--r-- | askama_parser/src/node.rs | 3 |
3 files changed, 17 insertions, 18 deletions
diff --git a/askama_parser/src/expr.rs b/askama_parser/src/expr.rs index ad0c19e..d676e85 100644 --- a/askama_parser/src/expr.rs +++ b/askama_parser/src/expr.rs @@ -10,7 +10,7 @@ use nom::sequence::{pair, preceded, terminated, tuple}; use nom::{error_position, IResult}; use super::{ - char_lit, identifier, not_ws, num_lit, path_or_identifier, str_lit, ws, PathOrIdentifier, + char_lit, identifier, not_ws, num_lit, path_or_identifier, str_lit, ws, Level, PathOrIdentifier, }; macro_rules! expr_prec_layer { @@ -363,18 +363,3 @@ impl<'a> Suffix<'a> { map(preceded(take_till(not_ws), char('?')), |_| Self::Try)(i) } } - -#[derive(Clone, Copy, Default)] -pub(crate) struct Level(u8); - -impl Level { - fn nest(self, i: &str) -> Result<Level, nom::Err<nom::error::Error<&str>>> { - if self.0 >= Self::MAX_EXPR_DEPTH { - return Err(nom::Err::Failure(error_position!(i, ErrorKind::TooLarge))); - } - - Ok(Level(self.0 + 1)) - } - - const MAX_EXPR_DEPTH: u8 = 64; -} diff --git a/askama_parser/src/lib.rs b/askama_parser/src/lib.rs index 1e48262..de88a20 100644 --- a/askama_parser/src/lib.rs +++ b/askama_parser/src/lib.rs @@ -324,3 +324,18 @@ impl Default for Syntax<'static> { } } } + +#[derive(Clone, Copy, Default)] +pub(crate) struct Level(u8); + +impl Level { + fn nest(self, i: &str) -> Result<Level, nom::Err<nom::error::Error<&str>>> { + if self.0 >= Self::MAX_DEPTH { + return Err(nom::Err::Failure(error_position!(i, ErrorKind::TooLarge))); + } + + Ok(Level(self.0 + 1)) + } + + const MAX_DEPTH: u8 = 64; +} diff --git a/askama_parser/src/node.rs b/askama_parser/src/node.rs index a72c2fb..c3a59c6 100644 --- a/askama_parser/src/node.rs +++ b/askama_parser/src/node.rs @@ -13,9 +13,8 @@ use nom::{error_position, IResult}; use super::{ bool_lit, char_lit, identifier, is_ws, keyword, num_lit, path_or_identifier, skip_till, - str_lit, ws, Expr, PathOrIdentifier, State, + str_lit, ws, Expr, Level, PathOrIdentifier, State, }; -use crate::expr::Level; #[derive(Debug, PartialEq)] pub enum Node<'a> { |