mirror of
https://github.com/askama-rs/askama.git
synced 2025-10-02 15:25:19 +00:00
ci: update formatting for edition=2024
This commit is contained in:
parent
8256eadf5a
commit
4b44189809
@ -5,7 +5,7 @@ newline_style = "Unix"
|
|||||||
normalize_comments = true
|
normalize_comments = true
|
||||||
unstable_features = true
|
unstable_features = true
|
||||||
use_field_init_shorthand = true
|
use_field_init_shorthand = true
|
||||||
version = "Two"
|
style_edition = "2024"
|
||||||
|
|
||||||
ignore = [
|
ignore = [
|
||||||
"testing/tests/hello.rs",
|
"testing/tests/hello.rs",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
use criterion::{Criterion, black_box, criterion_group, criterion_main};
|
||||||
use rinja::filters::{escape, Html};
|
use rinja::filters::{Html, escape};
|
||||||
|
|
||||||
criterion_main!(benches);
|
criterion_main!(benches);
|
||||||
criterion_group!(benches, functions);
|
criterion_group!(benches, functions);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
use criterion::{Criterion, black_box, criterion_group, criterion_main};
|
||||||
use rinja::Template;
|
use rinja::Template;
|
||||||
|
|
||||||
criterion_main!(benches);
|
criterion_main!(benches);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::convert::Infallible;
|
use std::convert::Infallible;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use humansize::{ISizeFormatter, ToF64, DECIMAL};
|
use humansize::{DECIMAL, ISizeFormatter, ToF64};
|
||||||
|
|
||||||
/// Returns adequate string representation (in KB, ..) of number of bytes
|
/// Returns adequate string representation (in KB, ..) of number of bytes
|
||||||
///
|
///
|
||||||
|
@ -2,7 +2,7 @@ use std::convert::Infallible;
|
|||||||
use std::{fmt, io, str};
|
use std::{fmt, io, str};
|
||||||
|
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use serde_json::ser::{to_writer, PrettyFormatter, Serializer};
|
use serde_json::ser::{PrettyFormatter, Serializer, to_writer};
|
||||||
|
|
||||||
use super::FastWritable;
|
use super::FastWritable;
|
||||||
|
|
||||||
|
@ -22,17 +22,17 @@ mod num_traits;
|
|||||||
mod urlencode;
|
mod urlencode;
|
||||||
|
|
||||||
pub use builtin::{
|
pub use builtin::{
|
||||||
capitalize, center, fmt, format, indent, join, linebreaks, linebreaksbr, lower, lowercase,
|
PluralizeCount, capitalize, center, fmt, format, indent, join, linebreaks, linebreaksbr, lower,
|
||||||
paragraphbreaks, pluralize, title, trim, truncate, upper, uppercase, wordcount, PluralizeCount,
|
lowercase, paragraphbreaks, pluralize, title, trim, truncate, upper, uppercase, wordcount,
|
||||||
};
|
};
|
||||||
pub use escape::{
|
pub use escape::{
|
||||||
e, escape, safe, AutoEscape, AutoEscaper, Escaper, FastWritable, Html, HtmlSafe,
|
AutoEscape, AutoEscaper, Escaper, FastWritable, Html, HtmlSafe, HtmlSafeOutput, MaybeSafe,
|
||||||
HtmlSafeOutput, MaybeSafe, Safe, Text, Unsafe, Writable, WriteWritable,
|
Safe, Text, Unsafe, Writable, WriteWritable, e, escape, safe,
|
||||||
};
|
};
|
||||||
#[cfg(feature = "humansize")]
|
#[cfg(feature = "humansize")]
|
||||||
pub use humansize::filesizeformat;
|
pub use humansize::filesizeformat;
|
||||||
#[cfg(feature = "serde_json")]
|
#[cfg(feature = "serde_json")]
|
||||||
pub use json::{json, json_pretty, AsIndent};
|
pub use json::{AsIndent, json, json_pretty};
|
||||||
#[cfg(feature = "num-traits")]
|
#[cfg(feature = "num-traits")]
|
||||||
pub use num_traits::{abs, into_f64, into_isize};
|
pub use num_traits::{abs, into_f64, into_isize};
|
||||||
#[cfg(feature = "urlencode")]
|
#[cfg(feature = "urlencode")]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use num_traits::cast::NumCast;
|
|
||||||
use num_traits::Signed;
|
use num_traits::Signed;
|
||||||
|
use num_traits::cast::NumCast;
|
||||||
|
|
||||||
use crate::{Error, Result};
|
use crate::{Error, Result};
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ use std::convert::Infallible;
|
|||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
|
|
||||||
use percent_encoding::{utf8_percent_encode, AsciiSet, NON_ALPHANUMERIC};
|
use percent_encoding::{AsciiSet, NON_ALPHANUMERIC, utf8_percent_encode};
|
||||||
|
|
||||||
use crate::filters::{FastWritable, HtmlSafeOutput};
|
use crate::filters::{FastWritable, HtmlSafeOutput};
|
||||||
|
|
||||||
|
@ -34,14 +34,11 @@ where
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn next(&mut self) -> Option<(<I as Iterator>::Item, LoopItem)> {
|
fn next(&mut self) -> Option<(<I as Iterator>::Item, LoopItem)> {
|
||||||
self.iter.next().map(|(index, item)| {
|
self.iter.next().map(|(index, item)| {
|
||||||
(
|
(item, LoopItem {
|
||||||
item,
|
index,
|
||||||
LoopItem {
|
first: index == 0,
|
||||||
index,
|
last: self.iter.peek().is_none(),
|
||||||
first: index == 0,
|
})
|
||||||
last: self.iter.peek().is_none(),
|
|
||||||
},
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,8 @@ use std::fmt;
|
|||||||
#[doc(no_inline)]
|
#[doc(no_inline)]
|
||||||
pub use actix_web;
|
pub use actix_web;
|
||||||
use actix_web::body::BoxBody;
|
use actix_web::body::BoxBody;
|
||||||
use actix_web::http::header::HeaderValue;
|
|
||||||
use actix_web::http::StatusCode;
|
use actix_web::http::StatusCode;
|
||||||
|
use actix_web::http::header::HeaderValue;
|
||||||
use actix_web::{HttpResponse, HttpResponseBuilder, ResponseError};
|
use actix_web::{HttpResponse, HttpResponseBuilder, ResponseError};
|
||||||
#[doc(no_inline)]
|
#[doc(no_inline)]
|
||||||
pub use rinja::*;
|
pub use rinja::*;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
use axum::Router;
|
||||||
use axum::body::Body;
|
use axum::body::Body;
|
||||||
use axum::http::{Request, StatusCode};
|
use axum::http::{Request, StatusCode};
|
||||||
use axum::routing::get;
|
use axum::routing::get;
|
||||||
use axum::Router;
|
|
||||||
use http_body_util::BodyExt;
|
use http_body_util::BodyExt;
|
||||||
use rinja_axum::Template;
|
use rinja_axum::Template;
|
||||||
use tower::util::ServiceExt;
|
use tower::util::ServiceExt;
|
||||||
|
@ -14,7 +14,7 @@ use rustc_hash::FxBuildHasher;
|
|||||||
#[cfg(feature = "config")]
|
#[cfg(feature = "config")]
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
use crate::{CompileError, FileInfo, CRATE};
|
use crate::{CRATE, CompileError, FileInfo};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub(crate) struct Config {
|
pub(crate) struct Config {
|
||||||
@ -682,22 +682,19 @@ mod tests {
|
|||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(config.escapers, vec![
|
||||||
config.escapers,
|
(str_set(&["js"]), "::my_filters::Js".into()),
|
||||||
vec![
|
(
|
||||||
(str_set(&["js"]), "::my_filters::Js".into()),
|
str_set(&[
|
||||||
(
|
"html", "htm", "j2", "jinja", "jinja2", "rinja", "svg", "xml"
|
||||||
str_set(&[
|
]),
|
||||||
"html", "htm", "j2", "jinja", "jinja2", "rinja", "svg", "xml"
|
"::rinja::filters::Html".into()
|
||||||
]),
|
),
|
||||||
"::rinja::filters::Html".into()
|
(
|
||||||
),
|
str_set(&["md", "none", "txt", "yml", ""]),
|
||||||
(
|
"::rinja::filters::Text".into()
|
||||||
str_set(&["md", "none", "txt", "yml", ""]),
|
),
|
||||||
"::rinja::filters::Text".into()
|
]);
|
||||||
),
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "config")]
|
#[cfg(feature = "config")]
|
||||||
|
@ -20,7 +20,7 @@ use crate::config::WhitespaceHandling;
|
|||||||
use crate::heritage::{Context, Heritage};
|
use crate::heritage::{Context, Heritage};
|
||||||
use crate::html::write_escaped_str;
|
use crate::html::write_escaped_str;
|
||||||
use crate::input::{Source, TemplateInput};
|
use crate::input::{Source, TemplateInput};
|
||||||
use crate::{CompileError, FileInfo, MsgValidEscapers, BUILT_IN_FILTERS, CRATE};
|
use crate::{BUILT_IN_FILTERS, CRATE, CompileError, FileInfo, MsgValidEscapers};
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Debug)]
|
#[derive(Clone, Copy, PartialEq, Debug)]
|
||||||
enum EvaluatedResult {
|
enum EvaluatedResult {
|
||||||
|
@ -15,11 +15,11 @@ use std::collections::HashMap;
|
|||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use config::{read_config_file, Config};
|
use config::{Config, read_config_file};
|
||||||
use generator::{Generator, MapChain};
|
use generator::{Generator, MapChain};
|
||||||
use heritage::{Context, Heritage};
|
use heritage::{Context, Heritage};
|
||||||
use input::{Print, TemplateArgs, TemplateInput};
|
use input::{Print, TemplateArgs, TemplateInput};
|
||||||
use parser::{strip_common, Parsed, WithSpan};
|
use parser::{Parsed, WithSpan, strip_common};
|
||||||
#[cfg(not(feature = "__standalone"))]
|
#[cfg(not(feature = "__standalone"))]
|
||||||
use proc_macro::TokenStream as TokenStream12;
|
use proc_macro::TokenStream as TokenStream12;
|
||||||
#[cfg(feature = "__standalone")]
|
#[cfg(feature = "__standalone")]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
|
use criterion::{BatchSize, Criterion, criterion_group, criterion_main};
|
||||||
use quote::quote;
|
use quote::quote;
|
||||||
|
|
||||||
criterion_main!(benches);
|
criterion_main!(benches);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use criterion::{black_box, criterion_group, criterion_main, Criterion, Throughput};
|
use criterion::{Criterion, Throughput, black_box, criterion_group, criterion_main};
|
||||||
use rinja_parser::{Ast, Syntax};
|
use rinja_parser::{Ast, Syntax};
|
||||||
|
|
||||||
criterion_main!(benches);
|
criterion_main!(benches);
|
||||||
|
@ -11,8 +11,8 @@ use nom::multi::{fold_many0, many0, separated_list0, separated_list1};
|
|||||||
use nom::sequence::{pair, preceded, terminated, tuple};
|
use nom::sequence::{pair, preceded, terminated, tuple};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
char_lit, filter, identifier, keyword, not_ws, num_lit, path_or_identifier, str_lit, ws,
|
CharLit, ErrorContext, Level, Num, ParseResult, PathOrIdentifier, StrLit, WithSpan, char_lit,
|
||||||
CharLit, ErrorContext, Level, Num, ParseResult, PathOrIdentifier, StrLit, WithSpan,
|
filter, identifier, keyword, not_ws, num_lit, path_or_identifier, str_lit, ws,
|
||||||
};
|
};
|
||||||
|
|
||||||
macro_rules! expr_prec_layer {
|
macro_rules! expr_prec_layer {
|
||||||
|
@ -535,13 +535,10 @@ fn char_lit(i: &str) -> Result<(&str, CharLit<'_>), ParseErr<'_>> {
|
|||||||
|
|
||||||
let (nb, max_value, err1, err2) = match c {
|
let (nb, max_value, err1, err2) = match c {
|
||||||
Char::Literal | Char::Escaped => {
|
Char::Literal | Char::Escaped => {
|
||||||
return Ok((
|
return Ok((i, CharLit {
|
||||||
i,
|
prefix: b_prefix.map(|_| CharPrefix::Binary),
|
||||||
CharLit {
|
content: s,
|
||||||
prefix: b_prefix.map(|_| CharPrefix::Binary),
|
}));
|
||||||
content: s,
|
|
||||||
},
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
Char::AsciiEscape(nb) => (
|
Char::AsciiEscape(nb) => (
|
||||||
nb,
|
nb,
|
||||||
@ -566,13 +563,10 @@ fn char_lit(i: &str) -> Result<(&str, CharLit<'_>), ParseErr<'_>> {
|
|||||||
return Err(nom::Err::Failure(ErrorContext::new(err2, start)));
|
return Err(nom::Err::Failure(ErrorContext::new(err2, start)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok((
|
Ok((i, CharLit {
|
||||||
i,
|
prefix: b_prefix.map(|_| CharPrefix::Binary),
|
||||||
CharLit {
|
content: s,
|
||||||
prefix: b_prefix.map(|_| CharPrefix::Binary),
|
}))
|
||||||
content: s,
|
|
||||||
},
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents the different kinds of char declarations:
|
/// Represents the different kinds of char declarations:
|
||||||
@ -1161,13 +1155,10 @@ mod test {
|
|||||||
// Check with `b` prefix.
|
// Check with `b` prefix.
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
char_lit("b'a'").unwrap(),
|
char_lit("b'a'").unwrap(),
|
||||||
(
|
("", crate::CharLit {
|
||||||
"",
|
prefix: Some(crate::CharPrefix::Binary),
|
||||||
crate::CharLit {
|
content: "a"
|
||||||
prefix: Some(crate::CharPrefix::Binary),
|
})
|
||||||
content: "a"
|
|
||||||
}
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Should fail.
|
// Should fail.
|
||||||
@ -1185,23 +1176,17 @@ mod test {
|
|||||||
fn test_str_lit() {
|
fn test_str_lit() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
str_lit(r#"b"hello""#).unwrap(),
|
str_lit(r#"b"hello""#).unwrap(),
|
||||||
(
|
("", StrLit {
|
||||||
"",
|
prefix: Some(StrPrefix::Binary),
|
||||||
StrLit {
|
content: "hello"
|
||||||
prefix: Some(StrPrefix::Binary),
|
})
|
||||||
content: "hello"
|
|
||||||
}
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
str_lit(r#"c"hello""#).unwrap(),
|
str_lit(r#"c"hello""#).unwrap(),
|
||||||
(
|
("", StrLit {
|
||||||
"",
|
prefix: Some(StrPrefix::CLike),
|
||||||
StrLit {
|
content: "hello"
|
||||||
prefix: Some(StrPrefix::CLike),
|
})
|
||||||
content: "hello"
|
|
||||||
}
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
assert!(str_lit(r#"d"hello""#).is_err());
|
assert!(str_lit(r#"d"hello""#).is_err());
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,8 @@ use nom::sequence::{delimited, pair, preceded, tuple};
|
|||||||
|
|
||||||
use crate::memchr_splitter::{Splitter1, Splitter2, Splitter3};
|
use crate::memchr_splitter::{Splitter1, Splitter2, Splitter3};
|
||||||
use crate::{
|
use crate::{
|
||||||
filter, identifier, is_ws, keyword, not_ws, skip_till, str_lit_without_prefix, ws,
|
ErrorContext, Expr, Filter, ParseResult, State, Target, WithSpan, filter, identifier, is_ws,
|
||||||
ErrorContext, Expr, Filter, ParseResult, State, Target, WithSpan,
|
keyword, not_ws, skip_till, str_lit_without_prefix, ws,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
@ -409,14 +409,11 @@ impl<'a> CondTest<'a> {
|
|||||||
ws(|i| Expr::parse(i, s.level.get())),
|
ws(|i| Expr::parse(i, s.level.get())),
|
||||||
)(i)?;
|
)(i)?;
|
||||||
let contains_bool_lit_or_is_defined = expr.contains_bool_lit_or_is_defined();
|
let contains_bool_lit_or_is_defined = expr.contains_bool_lit_or_is_defined();
|
||||||
Ok((
|
Ok((i, Self {
|
||||||
i,
|
target,
|
||||||
Self {
|
expr,
|
||||||
target,
|
contains_bool_lit_or_is_defined,
|
||||||
expr,
|
}))
|
||||||
contains_bool_lit_or_is_defined,
|
|
||||||
},
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1414,7 +1411,7 @@ fn is_rust_keyword(ident: &str) -> bool {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod kws_tests {
|
mod kws_tests {
|
||||||
use super::{is_rust_keyword, KWS, KWS_EXTRA, MAX_REPL_LEN};
|
use super::{KWS, KWS_EXTRA, MAX_REPL_LEN, is_rust_keyword};
|
||||||
|
|
||||||
fn ensure_utf8_inner(entry: &[&[[u8; MAX_REPL_LEN]]]) {
|
fn ensure_utf8_inner(entry: &[&[[u8; MAX_REPL_LEN]]]) {
|
||||||
for kws in entry {
|
for kws in entry {
|
||||||
|
@ -6,8 +6,8 @@ use nom::multi::separated_list1;
|
|||||||
use nom::sequence::{pair, preceded, tuple};
|
use nom::sequence::{pair, preceded, tuple};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
bool_lit, char_lit, identifier, keyword, num_lit, path_or_identifier, str_lit, ws, CharLit,
|
CharLit, ErrorContext, Num, ParseErr, ParseResult, PathOrIdentifier, State, StrLit, WithSpan,
|
||||||
ErrorContext, Num, ParseErr, ParseResult, PathOrIdentifier, State, StrLit, WithSpan,
|
bool_lit, char_lit, identifier, keyword, num_lit, path_or_identifier, str_lit, ws,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
|
@ -112,13 +112,9 @@ fn test_parse_numbers() {
|
|||||||
fn test_parse_var() {
|
fn test_parse_var() {
|
||||||
let s = Syntax::default();
|
let s = Syntax::default();
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(Ast::from_str("{{ foo }}", None, &s).unwrap().nodes, vec![
|
||||||
Ast::from_str("{{ foo }}", None, &s).unwrap().nodes,
|
Node::Expr(Ws(None, None), WithSpan::no_span(Expr::Var("foo")))
|
||||||
vec![Node::Expr(
|
],);
|
||||||
Ws(None, None),
|
|
||||||
WithSpan::no_span(Expr::Var("foo"))
|
|
||||||
)],
|
|
||||||
);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Ast::from_str("{{ foo_bar }}", None, &s).unwrap().nodes,
|
Ast::from_str("{{ foo_bar }}", None, &s).unwrap().nodes,
|
||||||
vec![Node::Expr(
|
vec![Node::Expr(
|
||||||
@ -127,26 +123,18 @@ fn test_parse_var() {
|
|||||||
)],
|
)],
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(Ast::from_str("{{ none }}", None, &s).unwrap().nodes, vec![
|
||||||
Ast::from_str("{{ none }}", None, &s).unwrap().nodes,
|
Node::Expr(Ws(None, None), WithSpan::no_span(Expr::Var("none")))
|
||||||
vec![Node::Expr(
|
],);
|
||||||
Ws(None, None),
|
|
||||||
WithSpan::no_span(Expr::Var("none"))
|
|
||||||
)],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_const() {
|
fn test_parse_const() {
|
||||||
let s = Syntax::default();
|
let s = Syntax::default();
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(Ast::from_str("{{ FOO }}", None, &s).unwrap().nodes, vec![
|
||||||
Ast::from_str("{{ FOO }}", None, &s).unwrap().nodes,
|
Node::Expr(Ws(None, None), WithSpan::no_span(Expr::Path(vec!["FOO"])))
|
||||||
vec![Node::Expr(
|
],);
|
||||||
Ws(None, None),
|
|
||||||
WithSpan::no_span(Expr::Path(vec!["FOO"]))
|
|
||||||
)],
|
|
||||||
);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Ast::from_str("{{ FOO_BAR }}", None, &s).unwrap().nodes,
|
Ast::from_str("{{ FOO_BAR }}", None, &s).unwrap().nodes,
|
||||||
vec![Node::Expr(
|
vec![Node::Expr(
|
||||||
@ -155,26 +143,18 @@ fn test_parse_const() {
|
|||||||
)],
|
)],
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(Ast::from_str("{{ NONE }}", None, &s).unwrap().nodes, vec![
|
||||||
Ast::from_str("{{ NONE }}", None, &s).unwrap().nodes,
|
Node::Expr(Ws(None, None), WithSpan::no_span(Expr::Path(vec!["NONE"])))
|
||||||
vec![Node::Expr(
|
],);
|
||||||
Ws(None, None),
|
|
||||||
WithSpan::no_span(Expr::Path(vec!["NONE"]))
|
|
||||||
)],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_path() {
|
fn test_parse_path() {
|
||||||
let s = Syntax::default();
|
let s = Syntax::default();
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(Ast::from_str("{{ None }}", None, &s).unwrap().nodes, vec![
|
||||||
Ast::from_str("{{ None }}", None, &s).unwrap().nodes,
|
Node::Expr(Ws(None, None), WithSpan::no_span(Expr::Path(vec!["None"])))
|
||||||
vec![Node::Expr(
|
],);
|
||||||
Ws(None, None),
|
|
||||||
WithSpan::no_span(Expr::Path(vec!["None"]))
|
|
||||||
)],
|
|
||||||
);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Ast::from_str("{{ Some(123) }}", None, &s).unwrap().nodes,
|
Ast::from_str("{{ Some(123) }}", None, &s).unwrap().nodes,
|
||||||
vec![Node::Expr(
|
vec![Node::Expr(
|
||||||
@ -328,41 +308,36 @@ fn test_rust_macro() {
|
|||||||
WithSpan::no_span(Expr::RustMacro(vec!["alloc", "vec"], "1, 2, 3")),
|
WithSpan::no_span(Expr::RustMacro(vec!["alloc", "vec"], "1, 2, 3")),
|
||||||
)],
|
)],
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(Ast::from_str("{{a!()}}", None, &syntax).unwrap().nodes, [
|
||||||
Ast::from_str("{{a!()}}", None, &syntax).unwrap().nodes,
|
Node::Expr(
|
||||||
[Node::Expr(
|
|
||||||
Ws(None, None),
|
Ws(None, None),
|
||||||
WithSpan::no_span(Expr::RustMacro(vec!["a"], ""))
|
WithSpan::no_span(Expr::RustMacro(vec!["a"], ""))
|
||||||
)],
|
)
|
||||||
);
|
],);
|
||||||
assert_eq!(
|
assert_eq!(Ast::from_str("{{a !()}}", None, &syntax).unwrap().nodes, [
|
||||||
Ast::from_str("{{a !()}}", None, &syntax).unwrap().nodes,
|
Node::Expr(
|
||||||
[Node::Expr(
|
|
||||||
Ws(None, None),
|
Ws(None, None),
|
||||||
WithSpan::no_span(Expr::RustMacro(vec!["a"], ""))
|
WithSpan::no_span(Expr::RustMacro(vec!["a"], ""))
|
||||||
)],
|
)
|
||||||
);
|
],);
|
||||||
assert_eq!(
|
assert_eq!(Ast::from_str("{{a! ()}}", None, &syntax).unwrap().nodes, [
|
||||||
Ast::from_str("{{a! ()}}", None, &syntax).unwrap().nodes,
|
Node::Expr(
|
||||||
[Node::Expr(
|
|
||||||
Ws(None, None),
|
Ws(None, None),
|
||||||
WithSpan::no_span(Expr::RustMacro(vec!["a"], ""))
|
WithSpan::no_span(Expr::RustMacro(vec!["a"], ""))
|
||||||
)],
|
)
|
||||||
);
|
],);
|
||||||
assert_eq!(
|
assert_eq!(Ast::from_str("{{a ! ()}}", None, &syntax).unwrap().nodes, [
|
||||||
Ast::from_str("{{a ! ()}}", None, &syntax).unwrap().nodes,
|
Node::Expr(
|
||||||
[Node::Expr(
|
|
||||||
Ws(None, None),
|
Ws(None, None),
|
||||||
WithSpan::no_span(Expr::RustMacro(vec!["a"], ""))
|
WithSpan::no_span(Expr::RustMacro(vec!["a"], ""))
|
||||||
)],
|
)
|
||||||
);
|
],);
|
||||||
assert_eq!(
|
assert_eq!(Ast::from_str("{{A!()}}", None, &syntax).unwrap().nodes, [
|
||||||
Ast::from_str("{{A!()}}", None, &syntax).unwrap().nodes,
|
Node::Expr(
|
||||||
[Node::Expr(
|
|
||||||
Ws(None, None),
|
Ws(None, None),
|
||||||
WithSpan::no_span(Expr::RustMacro(vec!["A"], ""))
|
WithSpan::no_span(Expr::RustMacro(vec!["A"], ""))
|
||||||
)],
|
)
|
||||||
);
|
],);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
&*Ast::from_str("{{a.b.c!( hello )}}", None, &syntax)
|
&*Ast::from_str("{{a.b.c!( hello )}}", None, &syntax)
|
||||||
.unwrap_err()
|
.unwrap_err()
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::hint::black_box;
|
use std::hint::black_box;
|
||||||
use std::iter::repeat;
|
use std::iter::repeat;
|
||||||
|
|
||||||
use criterion::{criterion_group, criterion_main, Criterion};
|
use criterion::{Criterion, criterion_group, criterion_main};
|
||||||
use rinja::Template;
|
use rinja::Template;
|
||||||
|
|
||||||
criterion_main!(benches);
|
criterion_main!(benches);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::iter::FusedIterator;
|
use std::iter::FusedIterator;
|
||||||
|
|
||||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
use criterion::{Criterion, black_box, criterion_group, criterion_main};
|
||||||
|
|
||||||
criterion_main!(benches);
|
criterion_main!(benches);
|
||||||
criterion_group!(benches, functions);
|
criterion_group!(benches, functions);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user