Struct datafusion_common::tree_node::Transformed
source · pub struct Transformed<T> {
pub data: T,
pub transformed: bool,
pub tnr: TreeNodeRecursion,
}
Expand description
This struct is used by tree transformation APIs such as
TreeNode::rewrite
,TreeNode::transform_down
,TreeNode::transform_down_mut
,TreeNode::transform_up
,TreeNode::transform_up_mut
,TreeNode::transform_down_up
to control the transformation and return the transformed result.
Specifically, API users can provide transformation closures or TreeNodeRewriter
implementations to control the transformation by returning:
- The resulting (possibly transformed) node,
- A flag indicating whether any change was made to the node, and
- A flag specifying how to proceed with the recursion.
At the end of the transformation, the return value will contain:
- The final (possibly transformed) tree,
- A flag indicating whether any change was made to the tree, and
- A flag specifying how the recursion ended.
Fields§
§data: T
§transformed: bool
§tnr: TreeNodeRecursion
Implementations§
source§impl<T> Transformed<T>
impl<T> Transformed<T>
sourcepub fn new(data: T, transformed: bool, tnr: TreeNodeRecursion) -> Self
pub fn new(data: T, transformed: bool, tnr: TreeNodeRecursion) -> Self
Create a new Transformed
object with the given information.
sourcepub fn yes(data: T) -> Self
pub fn yes(data: T) -> Self
Wrapper for transformed data with TreeNodeRecursion::Continue
statement.
sourcepub fn no(data: T) -> Self
pub fn no(data: T) -> Self
Wrapper for unchanged data with TreeNodeRecursion::Continue
statement.
sourcepub fn update_data<U, F: FnOnce(T) -> U>(self, f: F) -> Transformed<U>
pub fn update_data<U, F: FnOnce(T) -> U>(self, f: F) -> Transformed<U>
Applies the given f
to the data of this Transformed
object.
sourcepub fn map_data<U, F: FnOnce(T) -> Result<U>>(
self,
f: F
) -> Result<Transformed<U>>
pub fn map_data<U, F: FnOnce(T) -> Result<U>>( self, f: F ) -> Result<Transformed<U>>
Maps the data of Transformed
object to the result of the given f
.
sourcepub fn try_transform_node<F: FnOnce(T) -> Result<Transformed<T>>>(
self,
f: F
) -> Result<Transformed<T>>
pub fn try_transform_node<F: FnOnce(T) -> Result<Transformed<T>>>( self, f: F ) -> Result<Transformed<T>>
If TreeNodeRecursion
of the node is TreeNodeRecursion::Continue
or
TreeNodeRecursion::Jump
, transformation is applied to the node.
Otherwise, it remains as it is.
Trait Implementations§
source§impl<T: Debug> Debug for Transformed<T>
impl<T: Debug> Debug for Transformed<T>
source§impl<T: PartialEq> PartialEq for Transformed<T>
impl<T: PartialEq> PartialEq for Transformed<T>
source§fn eq(&self, other: &Transformed<T>) -> bool
fn eq(&self, other: &Transformed<T>) -> bool
self
and other
values to be equal, and is used
by ==
.