aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-symfony-console/src/helper/table_rows.rs
blob: 214ebab0bea9e05c82a5d115af68c1914e7c06c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//! ref: composer/vendor/symfony/console/Helper/TableRows.php

use crate::helper::Row;

/// @internal
///
/// In PHP this wraps a `\Closure` yielding a `\Traversable` of row groups. The generator
/// borrows the Table to lazily call `fillCells()`. For the Rust port we precompute the row
/// groups eagerly (see `Table::build_table_rows`) and store them here.
#[derive(Debug)]
pub struct TableRows {
    row_groups: Vec<Vec<Row>>,
}

impl TableRows {
    pub fn from_row_groups(row_groups: Vec<Vec<Row>>) -> Self {
        Self { row_groups }
    }
}

impl<'a> IntoIterator for &'a TableRows {
    type Item = &'a Vec<Row>;
    type IntoIter = std::slice::Iter<'a, Vec<Row>>;

    fn into_iter(self) -> Self::IntoIter {
        self.row_groups.iter()
    }
}