This is an automated email from the ASF dual-hosted git repository.

tustvold pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git


The following commit(s) were added to refs/heads/master by this push:
     new bca2f3ab9f6 Derive `Copy` for `TimeUnit` and `IntervalUnit` (#5840)
bca2f3ab9f6 is described below

commit bca2f3ab9f649d4f45674d1fb629f1e3068a8480
Author: Matthijs Brobbel <[email protected]>
AuthorDate: Tue Jun 4 20:02:51 2024 +0200

    Derive `Copy` for `TimeUnit` and `IntervalUnit` (#5840)
    
    * Derive `Copy` for `TimeUnit` and `IntervalUnit`
    
    * Fix clippy warnings
    
    * Rustfmt
---
 arrow-cast/src/cast/mod.rs   | 10 +++-------
 arrow-schema/src/datatype.rs |  4 ++--
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/arrow-cast/src/cast/mod.rs b/arrow-cast/src/cast/mod.rs
index df7dc3bc73d..ae2240bd940 100644
--- a/arrow-cast/src/cast/mod.rs
+++ b/arrow-cast/src/cast/mod.rs
@@ -1660,7 +1660,7 @@ pub fn cast_with_options(
             let array = cast_with_options(array, &Int64, cast_options)?;
             Ok(make_timestamp_array(
                 array.as_primitive(),
-                unit.clone(),
+                *unit,
                 tz.clone(),
             ))
         }
@@ -1721,11 +1721,7 @@ pub fn cast_with_options(
                 }
                 _ => converted,
             };
-            Ok(make_timestamp_array(
-                &adjusted,
-                to_unit.clone(),
-                to_tz.clone(),
-            ))
+            Ok(make_timestamp_array(&adjusted, *to_unit, to_tz.clone()))
         }
         (Timestamp(TimeUnit::Microsecond, _), Date32) => {
             
timestamp_to_date32(array.as_primitive::<TimestampMicrosecondType>())
@@ -4020,7 +4016,7 @@ mod tests {
                 TimeUnit::Microsecond,
                 TimeUnit::Nanosecond,
             ] {
-                let to_type = DataType::Timestamp(time_unit.clone(), None);
+                let to_type = DataType::Timestamp(*time_unit, None);
                 let b = cast(array, &to_type).unwrap();
 
                 match time_unit {
diff --git a/arrow-schema/src/datatype.rs b/arrow-schema/src/datatype.rs
index 449d363db67..049a4130c5e 100644
--- a/arrow-schema/src/datatype.rs
+++ b/arrow-schema/src/datatype.rs
@@ -327,7 +327,7 @@ pub enum DataType {
 }
 
 /// An absolute length of time in seconds, milliseconds, microseconds or 
nanoseconds.
-#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
 #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
 pub enum TimeUnit {
     /// Time in seconds.
@@ -341,7 +341,7 @@ pub enum TimeUnit {
 }
 
 /// YEAR_MONTH, DAY_TIME, MONTH_DAY_NANO interval in SQL style.
-#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
 #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
 pub enum IntervalUnit {
     /// Indicates the number of elapsed whole months, stored as 4-byte 
integers.

Reply via email to