diff --git a/arrow/src/array/data.rs b/arrow/src/array/data.rs index d02998f6807..b2547fefd16 100644 --- a/arrow/src/array/data.rs +++ b/arrow/src/array/data.rs @@ -727,7 +727,7 @@ impl ArrayData { ) -> Result<()> { // Justification: buffer size was validated above let offsets = self.typed_offsets::(buffer)?; - if offsets.len() == 0 { + if offsets.is_empty() { return Ok(()); } @@ -2088,9 +2088,8 @@ mod tests { /// Test that the list of type `data_type` generates correct offset out of bounds errors fn check_list_offsets(data_type: DataType) { - let values: Int32Array = [Some(1), Some(2), Some(3), Some(4)] - .into_iter() - .collect(); + let values: Int32Array = + [Some(1), Some(2), Some(3), Some(4)].into_iter().collect(); // 5 is an invalid offset into a list of only three values let offsets: Vec = [0, 2, 5, 4] @@ -2135,9 +2134,8 @@ mod tests { expected = "Offset invariant failure: Could not convert end_offset -1 to usize in slot 2" )] fn test_validate_list_negative_offsets() { - let values: Int32Array = [Some(1), Some(2), Some(3), Some(4)] - .into_iter() - .collect(); + let values: Int32Array = + [Some(1), Some(2), Some(3), Some(4)].into_iter().collect(); let field_type = Field::new("f", values.data_type().clone(), true); let data_type = DataType::List(Box::new(field_type)); @@ -2157,7 +2155,6 @@ mod tests { .unwrap(); } - #[test] #[should_panic( expected = "child #0 invalid: Invalid argument error: Value at position 1 out of bounds: -1 (can not convert to usize)" @@ -2175,29 +2172,23 @@ mod tests { ); // purposely create an invalid child data - let dict_data = unsafe { ArrayData::new_unchecked( - dict_data_type, - 1, - None, - None, - 0, - vec![keys.data().buffers[0].clone()], - vec![values.data().clone()], - )}; + let dict_data = unsafe { + ArrayData::new_unchecked( + dict_data_type, + 1, + None, + None, + 0, + vec![keys.data().buffers[0].clone()], + vec![values.data().clone()], + ) + }; // Now, try and create a struct with this invalid child data (and expect an error) - let data_type = DataType::Struct(vec![Field::new("d", dict_data.data_type().clone(), true)]); + let data_type = + DataType::Struct(vec![Field::new("d", dict_data.data_type().clone(), true)]); - ArrayData::try_new( - data_type, - 1, - None, - None, - 0, - vec![], - vec![dict_data], - ) - .unwrap(); + ArrayData::try_new(data_type, 1, None, None, 0, vec![], vec![dict_data]).unwrap(); } /// returns a buffer initialized with some constant value for tests