Skip to main content

ArrayExt

Trait ArrayExt 

Source
pub trait ArrayExt {
    // Required methods
    fn downcast<A: Array>(&self) -> Option<&A>;
    fn try_downcast<A: Array>(&self) -> Result<&A>;
}
Expand description

Downcast helpers on dyn Array.

use astrs_data::array::{ArrayExt, ArrayRef, Int32Array, IntoArrayRef, StringArray};

let column: ArrayRef = Int32Array::from_values([1, 2]).into_array_ref();
assert!(column.downcast::<Int32Array>().is_some());
assert!(column.downcast::<StringArray>().is_none());
assert!(column.try_downcast::<StringArray>().is_err());

Required Methods§

Source

fn downcast<A: Array>(&self) -> Option<&A>

Downcasts to a concrete array type, or None on a type mismatch.

Source

fn try_downcast<A: Array>(&self) -> Result<&A>

Downcasts to a concrete array type.

§Errors

DataError::DowncastFailed on a type mismatch, naming both the requested Rust type and the actual DataType.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§