martin-g commented on code in PR #21762:
URL: https://github.com/apache/datafusion/pull/21762#discussion_r3122958486


##########
datafusion/physical-expr-common/src/metrics/mod.rs:
##########
@@ -225,6 +226,11 @@ impl MetricsSet {
         self.metrics.push(metric)
     }
 
+    /// Extends the current list of metrics with the provided ones
+    pub fn extend(&mut self, metrics: impl Iterator<Item = Arc<Metric>>) {

Review Comment:
   ```suggestion
       pub fn extend(&mut self, metrics: impl IntoIterator<Item = Arc<Metric>>) 
{
   ```
   https://doc.rust-lang.org/stable/std/iter/trait.Extend.html#tymethod.extend



##########
datafusion/physical-expr-common/src/metrics/mod.rs:
##########
@@ -432,6 +438,15 @@ impl Display for MetricsSet {
     }
 }
 
+impl IntoIterator for MetricsSet {

Review Comment:
   Consider adding similar impl for `&MetricSet` too.



##########
datafusion/physical-expr-common/src/metrics/mod.rs:
##########
@@ -26,6 +26,7 @@ mod value;
 use datafusion_common::HashMap;
 pub use datafusion_common::format::{MetricCategory, MetricType};
 use parking_lot::Mutex;
+use std::vec::IntoIter;

Review Comment:
   nit: move the import inside `use std::{...}` below



##########
datafusion/physical-expr-common/src/metrics/mod.rs:
##########
@@ -432,6 +438,15 @@ impl Display for MetricsSet {
     }
 }
 
+impl IntoIterator for MetricsSet {
+    type Item = Arc<Metric>;
+    type IntoIter = IntoIter<Self::Item>;
+
+    fn into_iter(self) -> Self::IntoIter {
+        self.metrics.into_iter()
+    }
+}
+

Review Comment:
   Also consider adding 
[FromIterator](https://doc.rust-lang.org/stable/std/iter/trait.FromIterator.html)
 impl for friendlier `.collect()`
   ```suggestion
   
   impl FromIterator<Arc<Metric>> for MetricsSet {
       fn from_iter<T: IntoIterator<Item = Arc<Metric>>>(iter: T) -> Self {
           Self {
               metrics: iter.into_iter().collect(),
           }
       }
   }
   
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to