Commit 885461e 1 parent c5ab64c commit 885461e Copy full SHA for 885461e
File tree 1 file changed +5
-3
lines changed
1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -226,9 +226,10 @@ impl UnionArray {
226
226
///
227
227
/// # Panics
228
228
///
229
- /// Panics if the `type_id` provided is less than zero or greater than the number of types
229
+ /// Panics if the `type_id` provided is not present in the array's DataType
230
230
/// in the `Union`.
231
231
pub fn child ( & self , type_id : i8 ) -> & ArrayRef {
232
+ assert ! ( ( type_id as usize ) < self . fields. len( ) ) ;
232
233
let boxed = & self . fields [ type_id as usize ] ;
233
234
boxed. as_ref ( ) . expect ( "invalid type id" )
234
235
}
@@ -237,8 +238,9 @@ impl UnionArray {
237
238
///
238
239
/// # Panics
239
240
///
240
- /// Panics if `index` is greater than the length of the array.
241
+ /// Panics if `index` is greater than or equal to the number of child arrays
241
242
pub fn type_id ( & self , index : usize ) -> i8 {
243
+ assert ! ( index < self . type_ids. len( ) ) ;
242
244
self . type_ids [ index]
243
245
}
244
246
@@ -256,7 +258,7 @@ impl UnionArray {
256
258
///
257
259
/// # Panics
258
260
///
259
- /// Panics if `index` is greater than the length of the array.
261
+ /// Panics if `index` is greater than or equal the length of the array.
260
262
pub fn value_offset ( & self , index : usize ) -> usize {
261
263
assert ! ( index < self . len( ) ) ;
262
264
match & self . offsets {
You can’t perform that action at this time.
0 commit comments