alamb commented on code in PR #8044:
URL: https://github.com/apache/arrow-rs/pull/8044#discussion_r2257541332


##########
parquet-variant/src/variant.rs:
##########
@@ -1149,6 +1149,50 @@ impl From<i64> for Variant<'_, '_> {
     }
 }
 
+impl From<u8> for Variant<'_, '_> {
+    fn from(value: u8) -> Self {
+        // if it fits in i8, use that, otherwise use i16
+        if let Ok(value) = i8::try_from(value) {
+            Variant::Int8(value)
+        } else {
+            Variant::Int16(value as i16)
+        }
+    }
+}
+
+impl From<u16> for Variant<'_, '_> {
+    fn from(value: u16) -> Self {
+        // if it fits in i16, use that, otherwise use i32
+        if let Ok(value) = i16::try_from(value) {
+            Variant::Int16(value)
+        } else {
+            Variant::Int32(value as i32)
+        }
+    }

Review Comment:
   I agree it is a tossup -- I personally prefer the `if let Ok(...)` syntax
   
   Thank you for the comment



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to