MCPcopy Create free account
hub / github.com/apache/arrow-rs / try_from_fields

Method try_from_fields

arrow-schema/src/fields.rs:517–535  ·  view source on GitHub ↗

Create a new [`UnionFields`] from a collection of fields with automatically assigned type IDs starting from 0. The type IDs are assigned in increasing order: 0, 1, 2, 3, etc. This is the non-panicking version of [`UnionFields::from_fields`]. See # Errors Returns an error if the number of fields exceeds 127 (the maximum value fo

(fields: F)

Source from the content-addressed store, hash-verified

515 /// assert!(result.is_err());
516 /// ```
517 pub fn try_from_fields<F>(fields: F) -> Result<Self, ArrowError>
518 where
519 F: IntoIterator,
520 F::Item: Into<FieldRef>,
521 {
522 let mut out = Vec::with_capacity(i8::MAX as usize + 1);
523
524 for (i, field) in fields.into_iter().enumerate() {
525 let id = i8::try_from(i).map_err(|_| {
526 ArrowError::InvalidArgumentError(
527 "UnionFields cannot contain more than 128 fields".into(),
528 )
529 })?;
530
531 out.push((id, field.into()));
532 }
533
534 Ok(Self(out.into()))
535 }
536
537 /// Return size of this instance in bytes.
538 pub fn size(&self) -> usize {

Callers

nothing calls this directly

Calls 2

into_iterMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected