[][src]Struct tubular::Row

pub struct Row<'d> { /* fields omitted */ }

An opaque container for arbitrary types plucked from different Columns

Rows only exist derivatively from a DataFrame that holds them. They hold boxed references to the values owned by Columns.

Because Rows exist ephemerally, the number of cells and their types can't be known at compile time. The values are stored as Anys and must be downcast into the appropriate types to access the interior values. Row allows you to access values by specifying the column name or offset and supplying a type parameter which is forwarded to [downcast_ref] for you.

use tubular::DataFrame;

let mut df = DataFrame::default();
df.push("Fruits", &["apple", "pear", "mango"]);
df.push("Quantity", &[16, 25, 3]);
df.push("Organic", &[true, true, false]);

for row in df.rows() {
    let organic = *row.column_name::<bool>("Organic");
    let label = if organic { "Organic" } else { "" };
    println!("{} Fruit {} - {} available",
        label,
        row.column_name::<String>("Fruits"),
        row.column_name::<i32>("Quantity")
    );
}

Methods

impl<'d> Row<'d>[src]

pub fn len(&self) -> usize[src]

Number of cells in this Row

pub fn column_index<T>(&'d self, index: usize) -> &'d T where
    T: 'static + ColumnType
[src]

Returns the cell value by number and downcasts to T simultaneously.

Panics

This method panics if T does not match the type of the value at the provided index.

pub fn column_name<T>(&'d self, index: &'static str) -> &'d T where
    T: 'static + ColumnType
[src]

Returns the cell value by column name and downcasts to T simultaneously.

Panics

This method panics if T does not match the type of the value at the provided name.

Trait Implementations

impl<'d> Debug for Row<'d>[src]

impl<'d> Default for Row<'d>[src]

impl<'d> Index<&'static str> for Row<'d>[src]

type Output = Box<dyn Any>

The returned type after indexing.

impl<'d> Index<String> for Row<'d>[src]

type Output = Box<dyn Any>

The returned type after indexing.

impl<'d> Index<usize> for Row<'d>[src]

type Output = Box<dyn Any>

The returned type after indexing.

Auto Trait Implementations

impl<'d> !RefUnwindSafe for Row<'d>

impl<'d> !Send for Row<'d>

impl<'d> !Sync for Row<'d>

impl<'d> Unpin for Row<'d>

impl<'d> !UnwindSafe for Row<'d>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.