From 3768d8cb829292eac3e36c287939121b1c250f9c Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Tue, 8 Feb 2022 09:59:11 +0800 Subject: [PATCH] params --- datafusion/src/logical_plan/expr_rewriter.rs | 10 +++++----- datafusion/src/logical_plan/expr_visitor.rs | 12 +++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/datafusion/src/logical_plan/expr_rewriter.rs b/datafusion/src/logical_plan/expr_rewriter.rs index 30436352e525..67be9b7bf523 100644 --- a/datafusion/src/logical_plan/expr_rewriter.rs +++ b/datafusion/src/logical_plan/expr_rewriter.rs @@ -43,20 +43,20 @@ pub enum RewriteRecursion { /// tree. When passed to `Expr::rewrite`, `ExpressionVisitor::mutate` is /// invoked recursively on all nodes of an expression tree. See the /// comments on `Expr::rewrite` for details on its use -pub trait ExprRewriter: Sized { +pub trait ExprRewriter: Sized { /// Invoked before any children of `expr` are rewritten / /// visited. Default implementation returns `Ok(RewriteRecursion::Continue)` - fn pre_visit(&mut self, _expr: &Expr) -> Result { + fn pre_visit(&mut self, _expr: &E) -> Result { Ok(RewriteRecursion::Continue) } /// Invoked after all children of `expr` have been mutated and /// returns a potentially modified expr. - fn mutate(&mut self, expr: Expr) -> Result; + fn mutate(&mut self, expr: E) -> Result; } pub trait ExprRewritable: Sized { - fn rewrite(self, rewriter: &mut R) -> Result; + fn rewrite>(self, rewriter: &mut R) -> Result; } impl ExprRewritable for Expr { @@ -95,7 +95,7 @@ impl ExprRewritable for Expr { /// fn rewrite(self, rewriter: &mut R) -> Result where - R: ExprRewriter, + R: ExprRewriter, { let need_mutate = match rewriter.pre_visit(&self)? { RewriteRecursion::Mutate => return rewriter.mutate(self), diff --git a/datafusion/src/logical_plan/expr_visitor.rs b/datafusion/src/logical_plan/expr_visitor.rs index 0063e05b36a9..f983be51c4e6 100644 --- a/datafusion/src/logical_plan/expr_visitor.rs +++ b/datafusion/src/logical_plan/expr_visitor.rs @@ -33,19 +33,21 @@ pub enum Recursion { /// `Expr::accept`, `ExpressionVisitor::visit` is invoked /// recursively on all nodes of an expression tree. See the comments /// on `Expr::accept` for details on its use -pub trait ExpressionVisitor: Sized { +pub trait ExpressionVisitor: Sized { /// Invoked before any children of `expr` are visisted. - fn pre_visit(self, expr: &Expr) -> Result>; + fn pre_visit(self, expr: &E) -> Result> + where + Self: ExpressionVisitor; /// Invoked after all children of `expr` are visited. Default /// implementation does nothing. - fn post_visit(self, _expr: &Expr) -> Result { + fn post_visit(self, _expr: &E) -> Result { Ok(self) } } -pub trait ExprVisitable { - fn accept(&self, visitor: V) -> Result; +pub trait ExprVisitable: Sized { + fn accept>(&self, visitor: V) -> Result; } impl ExprVisitable for Expr {