@@ -84,7 +84,7 @@ impl Expr<'_> {
84
84
/// Returns `true` if the outcome of this expression may be used multiple times in the same
85
85
/// `write!()` call, without evaluating the expression again, i.e. the expression should be
86
86
/// side-effect free.
87
- pub ( crate ) fn is_cachable ( & self ) -> bool {
87
+ pub ( crate ) fn is_cacheable ( & self ) -> bool {
88
88
match self {
89
89
// Literals are the definition of pure:
90
90
Expr :: BoolLit ( _) => true ,
@@ -95,18 +95,18 @@ impl Expr<'_> {
95
95
Expr :: Var ( _) => true ,
96
96
Expr :: Path ( _) => true ,
97
97
// Check recursively:
98
- Expr :: Array ( args) => args. iter ( ) . all ( |arg| arg. is_cachable ( ) ) ,
99
- Expr :: Attr ( lhs, _) => lhs. is_cachable ( ) ,
100
- Expr :: Index ( lhs, rhs) => lhs. is_cachable ( ) && rhs. is_cachable ( ) ,
101
- Expr :: Filter ( _, args) => args. iter ( ) . all ( |arg| arg. is_cachable ( ) ) ,
102
- Expr :: Unary ( _, arg) => arg. is_cachable ( ) ,
103
- Expr :: BinOp ( _, lhs, rhs) => lhs. is_cachable ( ) && rhs. is_cachable ( ) ,
98
+ Expr :: Array ( args) => args. iter ( ) . all ( |arg| arg. is_cacheable ( ) ) ,
99
+ Expr :: Attr ( lhs, _) => lhs. is_cacheable ( ) ,
100
+ Expr :: Index ( lhs, rhs) => lhs. is_cacheable ( ) && rhs. is_cacheable ( ) ,
101
+ Expr :: Filter ( _, args) => args. iter ( ) . all ( |arg| arg. is_cacheable ( ) ) ,
102
+ Expr :: Unary ( _, arg) => arg. is_cacheable ( ) ,
103
+ Expr :: BinOp ( _, lhs, rhs) => lhs. is_cacheable ( ) && rhs. is_cacheable ( ) ,
104
104
Expr :: Range ( _, lhs, rhs) => {
105
- lhs. as_ref ( ) . map_or ( true , |v| v. is_cachable ( ) )
106
- && rhs. as_ref ( ) . map_or ( true , |v| v. is_cachable ( ) )
105
+ lhs. as_ref ( ) . map_or ( true , |v| v. is_cacheable ( ) )
106
+ && rhs. as_ref ( ) . map_or ( true , |v| v. is_cacheable ( ) )
107
107
}
108
- Expr :: Group ( arg) => arg. is_cachable ( ) ,
109
- Expr :: Tuple ( args) => args. iter ( ) . all ( |arg| arg. is_cachable ( ) ) ,
108
+ Expr :: Group ( arg) => arg. is_cacheable ( ) ,
109
+ Expr :: Tuple ( args) => args. iter ( ) . all ( |arg| arg. is_cacheable ( ) ) ,
110
110
// We have too little information to tell if the expression is pure:
111
111
Expr :: Call ( _, _) => false ,
112
112
Expr :: RustMacro ( _, _) => false ,
0 commit comments