From f9b2259cb7993d9aa0aab5745247c02206c524cf Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Mon, 3 Jul 2023 10:50:41 +0200 Subject: parser: reorder items in node module --- askama_parser/src/node.rs | 100 +++++++++++++++++++++++----------------------- 1 file changed, 50 insertions(+), 50 deletions(-) (limited to 'askama_parser/src') diff --git a/askama_parser/src/node.rs b/askama_parser/src/node.rs index 4e916fc..2a19ee9 100644 --- a/askama_parser/src/node.rs +++ b/askama_parser/src/node.rs @@ -578,42 +578,6 @@ impl<'a> Target<'a> { } } -#[derive(Clone, Copy, Debug, PartialEq)] -pub enum Whitespace { - Preserve, - Suppress, - Minimize, -} - -impl Whitespace { - fn parse(i: &str) -> IResult<&str, Self> { - alt((char('-'), char('+'), char('~')))(i).map(|(s, r)| (s, Self::from(r))) - } -} - -impl From for Whitespace { - fn from(c: char) -> Self { - match c { - '+' => Self::Preserve, - '-' => Self::Suppress, - '~' => Self::Minimize, - _ => panic!("unsupported `Whitespace` conversion"), - } - } -} - -#[derive(Debug, PartialEq)] -pub struct Loop<'a> { - pub ws1: Ws, - pub var: Target<'a>, - pub iter: Expr<'a>, - pub cond: Option>, - pub body: Vec>, - pub ws2: Ws, - pub else_block: Vec>, - pub ws3: Ws, -} - #[derive(Debug, PartialEq)] pub struct When<'a> { pub ws: Ws, @@ -669,20 +633,6 @@ impl<'a> When<'a> { } } -#[derive(Debug, PartialEq)] -pub struct Macro<'a> { - pub ws1: Ws, - pub args: Vec<&'a str>, - pub nodes: Vec>, - pub ws2: Ws, -} - -/// First field is "minus/plus sign was used on the left part of the item". -/// -/// Second field is "minus/plus sign was used on the right part of the item". -#[derive(Clone, Copy, Debug, PartialEq)] -pub struct Ws(pub Option, pub Option); - #[derive(Debug, PartialEq)] pub struct Cond<'a> { pub ws: Ws, @@ -738,3 +688,53 @@ impl<'a> CondTest<'a> { Ok((i, Self { target, expr })) } } + +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum Whitespace { + Preserve, + Suppress, + Minimize, +} + +impl Whitespace { + fn parse(i: &str) -> IResult<&str, Self> { + alt((char('-'), char('+'), char('~')))(i).map(|(s, r)| (s, Self::from(r))) + } +} + +impl From for Whitespace { + fn from(c: char) -> Self { + match c { + '+' => Self::Preserve, + '-' => Self::Suppress, + '~' => Self::Minimize, + _ => panic!("unsupported `Whitespace` conversion"), + } + } +} + +#[derive(Debug, PartialEq)] +pub struct Loop<'a> { + pub ws1: Ws, + pub var: Target<'a>, + pub iter: Expr<'a>, + pub cond: Option>, + pub body: Vec>, + pub ws2: Ws, + pub else_block: Vec>, + pub ws3: Ws, +} + +#[derive(Debug, PartialEq)] +pub struct Macro<'a> { + pub ws1: Ws, + pub args: Vec<&'a str>, + pub nodes: Vec>, + pub ws2: Ws, +} + +/// First field is "minus/plus sign was used on the left part of the item". +/// +/// Second field is "minus/plus sign was used on the right part of the item". +#[derive(Clone, Copy, Debug, PartialEq)] +pub struct Ws(pub Option, pub Option); -- cgit