tustvold commented on code in PR #2793:
URL: https://github.com/apache/arrow-rs/pull/2793#discussion_r982834210


##########
arrow-buffer/src/native.rs:
##########
@@ -46,229 +46,128 @@ mod private {
 pub trait ArrowNativeType:
     std::fmt::Debug + Send + Sync + Copy + PartialOrd + Default + 
private::Sealed + 'static
 {
-    /// Convert native type from usize.
-    #[inline]
-    fn from_usize(_: usize) -> Option<Self> {
-        None
-    }
+    /// Convert native integer type from usize
+    ///
+    /// Returns `None` if [`Self`] is not an integer or conversion would result
+    /// in truncation/overflow
+    fn from_usize(_: usize) -> Option<Self>;
+
+    /// Convert to usize according to the [`as`] operator
+    ///
+    /// [`as`]: 
https://doc.rust-lang.org/reference/expressions/operator-expr.html#numeric-cast
+    fn as_usize(self) -> usize;
 
     /// Convert native type to usize.
-    #[inline]
-    fn to_usize(&self) -> Option<usize> {
-        None
-    }
+    ///
+    /// Returns `None` if [`Self`] is not an integer or conversion would result
+    /// in truncation/overflow
+    fn to_usize(self) -> Option<usize>;
 
     /// Convert native type to isize.
-    #[inline]
-    fn to_isize(&self) -> Option<isize> {
-        None
-    }
+    ///
+    /// Returns `None` if [`Self`] is not an integer or conversion would result
+    /// in truncation/overflow
+    fn to_isize(self) -> Option<isize>;
 
     /// Convert native type from i32.
-    #[inline]
+    ///
+    /// Returns `None` if [`Self`] is not `i32`
+    #[deprecated(note = "please use `Option::Some` instead")]

Review Comment:
   The only case where the method returned something other than None is when 
the type matches, in which case Some is the same behaviour



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