diff --git a/arrow-cast/src/cast/list.rs b/arrow-cast/src/cast/list.rs index 0bc313da5322..f6c8d2465c86 100644 --- a/arrow-cast/src/cast/list.rs +++ b/arrow-cast/src/cast/list.rs @@ -24,7 +24,7 @@ pub(crate) fn cast_values_to_list( cast_options: &CastOptions, ) -> Result { let values = cast_with_options(array, to.data_type(), cast_options)?; - let offsets = OffsetBuffer::from_lengths(std::iter::repeat_n(1, values.len())); + let offsets = OffsetBuffer::from_repeated_length(1, values.len()); let list = GenericListArray::::try_new(to.clone(), offsets, values, None)?; Ok(Arc::new(list)) } diff --git a/arrow-cast/src/cast/mod.rs b/arrow-cast/src/cast/mod.rs index c825e2752d6c..fe38298b017c 100644 --- a/arrow-cast/src/cast/mod.rs +++ b/arrow-cast/src/cast/mod.rs @@ -2381,7 +2381,7 @@ fn cast_numeric_to_binary( ) -> Result { let array = array.as_primitive::(); let size = std::mem::size_of::(); - let offsets = OffsetBuffer::from_lengths(std::iter::repeat_n(size, array.len())); + let offsets = OffsetBuffer::from_repeated_length(size, array.len()); Ok(Arc::new(GenericBinaryArray::::try_new( offsets, array.values().inner().clone(),