mirror of
https://github.com/askama-rs/askama.git
synced 2025-10-04 00:05:12 +00:00
Move Level into the crate root
This commit is contained in:
parent
5ab8813fe2
commit
5718175291
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user