Skip to main content

StringArray

Struct StringArray 

Source
pub struct StringArray<D: Dimension> { /* private fields */ }
Expand description

A specialized N-dimensional array of strings.

Unlike ferray_core::Array, this type does not require Element — it stores Vec<String> directly with shape metadata for indexing.

The data is stored in row-major (C) order.

Implementations§

Source§

impl<D: Dimension> StringArray<D>

Source

pub fn from_vec(dim: D, data: Vec<String>) -> FerrayResult<Self>

Create a new StringArray from a flat vector of strings and a shape.

§Errors

Returns FerrayError::ShapeMismatch if data.len() does not equal the product of the shape dimensions.

Source

pub fn empty(dim: D) -> FerrayResult<Self>

Create a StringArray filled with empty strings.

§Errors

This function is infallible for valid shapes but returns Result for API consistency.

Source

pub fn shape(&self) -> &[usize]

Return the shape as a slice.

Source

pub fn ndim(&self) -> usize

Return the number of dimensions.

Source

pub fn len(&self) -> usize

Return the total number of elements.

Source

pub fn is_empty(&self) -> bool

Return true if the array has no elements.

Source

pub fn dim(&self) -> &D

Return a reference to the dimension descriptor.

Source

pub fn as_slice(&self) -> &[String]

Return a reference to the flat data.

Source

pub fn as_slice_mut(&mut self) -> &mut [String]

Return a mutable reference to the flat data.

Source

pub fn into_vec(self) -> Vec<String>

Consume self and return the underlying Vec<String>.

Source

pub fn map<F>(&self, f: F) -> FerrayResult<StringArray<D>>
where F: Fn(&str) -> String,

Apply a function to each element, producing a new StringArray.

Source

pub fn map_to_vec<T, F>(&self, f: F) -> Vec<T>
where F: Fn(&str) -> T,

Apply a function to each element, producing a Vec<T>.

This is a lower-level helper used by search and boolean operations that need to produce typed arrays (e.g., Array<bool, D>).

Source

pub fn iter(&self) -> Iter<'_, String>

Iterate over all elements.

Source§

impl StringArray<Ix1>

Source

pub fn from_slice(items: &[&str]) -> FerrayResult<Self>

Create a 1-D StringArray from a slice of string-like values.

§Examples
let a = StringArray1::from_slice(&["hello", "world"]).unwrap();
Source§

impl StringArray<Ix2>

Source

pub fn from_rows(rows: &[&[&str]]) -> FerrayResult<Self>

Create a 2-D StringArray from nested slices.

§Errors

Returns FerrayError::ShapeMismatch if inner slices have different lengths.

Source§

impl StringArray<IxDyn>

Source

pub fn from_vec_dyn(shape: &[usize], data: Vec<String>) -> FerrayResult<Self>

Create a dynamic-rank StringArray from a flat vec and a dynamic shape.

Trait Implementations§

Source§

impl<D: Clone + Dimension> Clone for StringArray<D>

Source§

fn clone(&self) -> StringArray<D>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<D: Debug + Dimension> Debug for StringArray<D>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<D: Dimension> PartialEq for StringArray<D>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<D: Dimension> Eq for StringArray<D>

Auto Trait Implementations§

§

impl<D> Freeze for StringArray<D>
where D: Freeze,

§

impl<D> RefUnwindSafe for StringArray<D>
where D: RefUnwindSafe,

§

impl<D> Send for StringArray<D>

§

impl<D> Sync for StringArray<D>

§

impl<D> Unpin for StringArray<D>
where D: Unpin,

§

impl<D> UnsafeUnpin for StringArray<D>
where D: UnsafeUnpin,

§

impl<D> UnwindSafe for StringArray<D>
where D: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.