Skip to content

Commit

Permalink
Merge pull request #204 from Kijewski/pr-lin
Browse files Browse the repository at this point in the history
derive: linearize recursive function
  • Loading branch information
GuillaumeGomez authored Oct 23, 2024
2 parents 35607ee + 3840951 commit 6a02bed
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions rinja_derive/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
}

Expand Down

0 comments on commit 6a02bed

Please sign in to comment.