Skip to main content

MiraArray

Trait MiraArray 

Source
pub trait MiraArray: Any {
    // Required methods
    fn len(&self) -> usize;
    fn get(
        &self,
        self_handle: MiraHandle<dyn MiraArray>,
        runtime: &Runtime,
        index: usize,
    ) -> Result<MiraManageable, Box<MiraError>>;

    // Provided methods
    fn iter<'a>(
        &'a self,
        self_handle: MiraHandle<dyn MiraArray>,
        runtime: &'a Runtime,
    ) -> Option<Box<dyn ExactSizeIterator<Item = Result<MiraArrayEntry, Box<MiraError>>> + 'a>> { ... }
    fn is_empty(&self) -> bool { ... }
}
Expand description

A read-only MiraScript array view.

Required Methods§

Source

fn len(&self) -> usize

Return the number of elements.

Source

fn get( &self, self_handle: MiraHandle<dyn MiraArray>, runtime: &Runtime, index: usize, ) -> Result<MiraManageable, Box<MiraError>>

Read one element by index.

Provided Methods§

Source

fn iter<'a>( &'a self, self_handle: MiraHandle<dyn MiraArray>, runtime: &'a Runtime, ) -> Option<Box<dyn ExactSizeIterator<Item = Result<MiraArrayEntry, Box<MiraError>>> + 'a>>

Return a more efficient sequential iterator when indexed reads are unsuitable.

The default None keeps full materialization on MiraArray::get. Implementations backed by containers without constant-time indexed access can return an iterator to avoid repeatedly traversing from the beginning.

Source

fn is_empty(&self) -> bool

Return whether the array is empty.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<T> MiraArray for Box<[T]>
where T: MiraField,

Source§

fn len(&self) -> usize

Source§

fn get( &self, self_handle: MiraHandle<dyn MiraArray>, _runtime: &Runtime, index: usize, ) -> Result<MiraManageable, Box<MiraError>>

Source§

impl<T> MiraArray for Vec<T>
where T: MiraField,

Source§

fn len(&self) -> usize

Source§

fn get( &self, self_handle: MiraHandle<dyn MiraArray>, _runtime: &Runtime, index: usize, ) -> Result<MiraManageable, Box<MiraError>>

Implementors§

Source§

impl<T> MiraArray for T
where T: MiraShapedArray,