[−][src]Struct tubular::Row
An opaque container for arbitrary types plucked from different Column
s
Row
s only exist derivatively from a DataFrame
that holds them. They hold boxed
references to the values owned by Column
s.
Because Row
s exist ephemerally, the number of cells and their types can't be known at compile
time. The values are stored as Any
s 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]
T: 'static + ColumnType,
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]
T: 'static + ColumnType,
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.
fn index(&self, index: &'static str) -> &Self::Output
[src]
impl<'d> Index<String> for Row<'d>
[src]
type Output = Box<dyn Any>
The returned type after indexing.
fn index(&self, index: String) -> &Self::Output
[src]
impl<'d> Index<usize> for Row<'d>
[src]
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,