mirror of
https://github.com/askama-rs/askama.git
synced 2025-10-01 06:51:15 +00:00
derive: linearize recursive function
This commit is contained in:
parent
35607eef43
commit
3840951ef3
@ -3007,11 +3007,13 @@ fn is_copyable_within_op(expr: &Expr<'_>, within_op: bool) -> bool {
|
||||
}
|
||||
|
||||
/// Returns `true` if this is an `Attr` where the `obj` is `"self"`.
|
||||
pub(crate) fn is_attr_self(expr: &Expr<'_>) -> bool {
|
||||
match expr {
|
||||
Expr::Attr(obj, _) if matches!(***obj, Expr::Var("self")) => true,
|
||||
Expr::Attr(obj, _) if matches!(***obj, Expr::Attr(..)) => is_attr_self(obj),
|
||||
_ => false,
|
||||
pub(crate) fn is_attr_self(mut expr: &Expr<'_>) -> bool {
|
||||
loop {
|
||||
match expr {
|
||||
Expr::Attr(obj, _) if matches!(***obj, Expr::Var("self")) => return true,
|
||||
Expr::Attr(obj, _) if matches!(***obj, Expr::Attr(..)) => expr = obj,
|
||||
_ => return false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user