gaoxinge commented on code in PR #5102:
URL: https://github.com/apache/arrow-datafusion/pull/5102#discussion_r1089979721


##########
datafusion/core/src/physical_plan/metrics/mod.rs:
##########
@@ -161,8 +161,8 @@ impl Metric {
     }
 
     /// return a reference to the partition
-    pub fn partition(&self) -> &Option<usize> {
-        &self.partition
+    pub fn partition(&self) -> Option<&usize> {
+        self.partition.as_ref()
     }

Review Comment:
   I use `.clone()` instead of `.copied()` or `.cloned()`, because the compiler 
will raise error in last case:
   
   ```
   error[E0599]: `Option<usize>` is not an iterator
      --> datafusion\core\src\physical_plan\metrics\mod.rs:165:24
       |
   165 |         self.partition.copied()
       |                        ^^^^^^ `Option<usize>` is not an iterator
       |
      ::: 
C:\Users\gaoxinge\.rustup\toolchains\nightly-x86_64-pc-windows-gnu\lib/rustlib/src/rust\library\core\src\option.rs:518:1
       |
   518 | pub enum Option<T> {
       | ------------------ doesn't satisfy `Option<usize>: Iterator`
       |
       = note: the following trait bounds were not satisfied:
               `Option<usize>: Iterator`
               which is required by `&mut Option<usize>: Iterator`
   ```
   
   This error may refer to [Strange .cloned() error message mentioning 
iterators](https://github.com/rust-lang/rust/issues/74121).
   



-- 
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]

Reply via email to