pub enum DynArray {
F32(Array<f32>),
F64(Array<f64>),
I32(Array<i32>),
I8(Array<i8>),
U8(Array<u8>),
Bool(Array<bool>),
}Expand description
Array con tipo borrado (type-erased) que puede contener cualquier dtype
Similar a como NumPy maneja arrays internamente: el dtype se conoce en runtime.
§Ejemplo
ⓘ
let a = DynArray::F32(Array::new(vec![2], vec![1.0, 2.0]));
let b = DynArray::I32(Array::new(vec![2], vec![3, 4]));
// Operaciones devuelven DynArray con tipo promovido
let result = ops::add_dyn(&a, &b)?; // -> DynArray::F32
// Pattern matching para extraer el tipo concreto
match result {
DynArray::F32(arr) => println!("f32: {:?}", arr.data),
DynArray::I32(arr) => println!("i32: {:?}", arr.data),
_ => {}
}Variants§
Implementations§
Source§impl DynArray
impl DynArray
Sourcepub fn into_typed<T: DTypeValue>(self) -> Result<Array<T>>
pub fn into_typed<T: DTypeValue>(self) -> Result<Array<T>>
Extract the inner Array
§Automatic Casting
If the internal dtype differs from T, this function will automatically cast/convert the data to T. This enables “automatic narrowing” (F64 -> F32) or normal promotion casting.
Sourcepub fn from_generic<T: DTypeValue>(arr: Array<T>) -> Self
pub fn from_generic<T: DTypeValue>(arr: Array<T>) -> Self
Envolver un Array
Esto usa unsafe para transmute, pero es seguro porque verificamos el dtype
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DynArray
impl RefUnwindSafe for DynArray
impl Send for DynArray
impl Sync for DynArray
impl Unpin for DynArray
impl UnwindSafe for DynArray
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more