mirror of
https://github.com/askama-rs/askama.git
synced 2025-10-02 23:35:07 +00:00
Use if cfg!()
to dedup code
This commit is contained in:
parent
3928e1df53
commit
e493d3fef2
@ -1201,21 +1201,15 @@ impl<'a> Generator<'a> {
|
|||||||
Ok(DisplayWrap::Unwrapped)
|
Ok(DisplayWrap::Unwrapped)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "serde-json"))]
|
|
||||||
fn _visit_json_filter(
|
|
||||||
&mut self,
|
|
||||||
_: &mut Buffer,
|
|
||||||
_: &[Expr<'_>],
|
|
||||||
) -> Result<DisplayWrap, CompileError> {
|
|
||||||
Err("the `json` filter requires the `serde-json` feature to be enabled".into())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "serde-json")]
|
|
||||||
fn _visit_json_filter(
|
fn _visit_json_filter(
|
||||||
&mut self,
|
&mut self,
|
||||||
buf: &mut Buffer,
|
buf: &mut Buffer,
|
||||||
args: &[Expr<'_>],
|
args: &[Expr<'_>],
|
||||||
) -> Result<DisplayWrap, CompileError> {
|
) -> Result<DisplayWrap, CompileError> {
|
||||||
|
if cfg!(not(feature = "serde-json")) {
|
||||||
|
return Err("the `json` filter requires the `serde-json` feature to be enabled".into());
|
||||||
|
}
|
||||||
|
|
||||||
if args.len() != 1 {
|
if args.len() != 1 {
|
||||||
return Err("unexpected argument(s) in `json` filter".into());
|
return Err("unexpected argument(s) in `json` filter".into());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user