From 6480020e695ebbe2b81e8971c3ee0e9e7ec124b0 Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Fri, 3 May 2024 05:52:04 -0400 Subject: [PATCH] Refine documentation for `Transformed::{update,map,transform})_data` (#10355) * Refine documentation for `Transformed::{update,map,transform})_data` * Update datafusion/common/src/tree_node.rs Co-authored-by: comphead --------- Co-authored-by: comphead --- datafusion/common/src/tree_node.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/datafusion/common/src/tree_node.rs b/datafusion/common/src/tree_node.rs index 43026f3a9206..9d42f4fb1e0d 100644 --- a/datafusion/common/src/tree_node.rs +++ b/datafusion/common/src/tree_node.rs @@ -625,17 +625,23 @@ impl Transformed { Self::new(data, false, TreeNodeRecursion::Continue) } - /// Applies the given `f` to the data of this [`Transformed`] object. + /// Applies an infallible `f` to the data of this [`Transformed`] object, + /// without modifying the `transformed` flag. pub fn update_data U>(self, f: F) -> Transformed { Transformed::new(f(self.data), self.transformed, self.tnr) } - /// Maps the data of [`Transformed`] object to the result of the given `f`. + /// Applies a fallible `f` (returns `Result`) to the data of this + /// [`Transformed`] object, without modifying the `transformed` flag. pub fn map_data Result>(self, f: F) -> Result> { f(self.data).map(|data| Transformed::new(data, self.transformed, self.tnr)) } - /// Maps the [`Transformed`] object to the result of the given `f`. + /// Applies a fallible transforming `f` to the data of this [`Transformed`] + /// object. + /// + /// The returned `Transformed` object has the `transformed` flag set if either + /// `self` or the return value of `f` have the `transformed` flag set. pub fn transform_data Result>>( self, f: F,