1/// The representation of data, rows and columns of a [`Grid`].
2///
3/// [`Grid`]: crate::grid::iterable::Grid
4pub trait IntoRecords {
5 /// A string representation of a [`Grid`] cell.
6 ///
7 /// [`Grid`]: crate::grid::iterable::Grid
8 type Cell;
9
10 /// Cell iterator inside a row.
11 type IterColumns: IntoIterator<Item = Self::Cell>;
12
13 /// Rows iterator.
14 type IterRows: IntoIterator<Item = Self::IterColumns>;
15
16 /// Returns an iterator over rows.
17 fn iter_rows(self) -> Self::IterRows;
18}
19
20impl<T> IntoRecords for T
21where
22 T: IntoIterator,
23 <T as IntoIterator>::Item: IntoIterator,
24{
25 type Cell = <<T as IntoIterator>::Item as IntoIterator>::Item;
26 type IterColumns = <T as IntoIterator>::Item;
27 type IterRows = <T as IntoIterator>::IntoIter;
28
29 fn iter_rows(self) -> Self::IterRows {
30 self.into_iter()
31 }
32}
33