diff --git a/rust/arrow/src/array/array_binary.rs b/rust/arrow/src/array/array_binary.rs index 9bc182eebb7..475e954ab9c 100644 --- a/rust/arrow/src/array/array_binary.rs +++ b/rust/arrow/src/array/array_binary.rs @@ -183,7 +183,9 @@ impl<'a, T: BinaryOffsetSizeTrait> GenericBinaryArray { impl fmt::Debug for GenericBinaryArray { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}BinaryArray\n[\n", OffsetSize::prefix())?; + let prefix = if OffsetSize::is_large() { "Large" } else { "" }; + + write!(f, "{}BinaryArray\n[\n", prefix)?; print_long_array(self, f, |array, index, f| { fmt::Debug::fmt(&array.value(index), f) })?; diff --git a/rust/arrow/src/array/array_list.rs b/rust/arrow/src/array/array_list.rs index 4eb9e5d479a..8117b8bde64 100644 --- a/rust/arrow/src/array/array_list.rs +++ b/rust/arrow/src/array/array_list.rs @@ -32,8 +32,6 @@ use crate::datatypes::{ArrowNativeType, ArrowPrimitiveType, DataType, Field}; /// trait declaring an offset size, relevant for i32 vs i64 array types. pub trait OffsetSizeTrait: ArrowNativeType + Num + Ord + std::ops::AddAssign { fn is_large() -> bool; - - fn prefix() -> &'static str; } impl OffsetSizeTrait for i32 { @@ -41,10 +39,6 @@ impl OffsetSizeTrait for i32 { fn is_large() -> bool { false } - - fn prefix() -> &'static str { - "" - } } impl OffsetSizeTrait for i64 { @@ -52,10 +46,6 @@ impl OffsetSizeTrait for i64 { fn is_large() -> bool { true } - - fn prefix() -> &'static str { - "Large" - } } pub struct GenericListArray { @@ -183,7 +173,7 @@ impl GenericListArray { .collect(); let field = Box::new(Field::new("item", T::DATA_TYPE, true)); - let data_type = if OffsetSize::prefix() == "Large" { + let data_type = if OffsetSize::is_large() { DataType::LargeList(field) } else { DataType::List(field) @@ -266,7 +256,9 @@ impl Array for GenericListArray fmt::Debug for GenericListArray { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}ListArray\n[\n", OffsetSize::prefix())?; + let prefix = if OffsetSize::is_large() { "Large" } else { "" }; + + write!(f, "{}ListArray\n[\n", prefix)?; print_long_array(self, f, |array, index, f| { fmt::Debug::fmt(&array.value(index), f) })?; diff --git a/rust/arrow/src/array/array_string.rs b/rust/arrow/src/array/array_string.rs index fa927bb35d6..bc6f2743072 100644 --- a/rust/arrow/src/array/array_string.rs +++ b/rust/arrow/src/array/array_string.rs @@ -268,7 +268,9 @@ impl<'a, T: StringOffsetSizeTrait> GenericStringArray { impl fmt::Debug for GenericStringArray { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}StringArray\n[\n", OffsetSize::prefix())?; + let prefix = if OffsetSize::is_large() { "Large" } else { "" }; + + write!(f, "{}StringArray\n[\n", prefix)?; print_long_array(self, f, |array, index, f| { fmt::Debug::fmt(&array.value(index), f) })?;