polars_rows_iter/
dataframe_rows_iter_ext.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use polars::prelude::*;

use crate::FromDataFrameRow;

pub trait DataframeRowsIterExt<'a> {
    fn rows_iter<T>(&'a self) -> PolarsResult<Box<dyn Iterator<Item = PolarsResult<T>> + 'a>>
    where
        T: FromDataFrameRow<'a>;
}

impl<'a> DataframeRowsIterExt<'a> for DataFrame {
    fn rows_iter<T>(&'a self) -> PolarsResult<Box<dyn Iterator<Item = PolarsResult<T>> + 'a>>
    where
        T: FromDataFrameRow<'a>,
    {
        Ok(T::from_dataframe(self)?)
    }
}