docs(table): add documentation for Table::new() (#471)

This commit is contained in:
Aizon 2023-09-06 00:41:47 +01:00 committed by GitHub
parent c95a75c5d5
commit 232be80325
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -268,6 +268,27 @@ pub struct Table<'a> {
}
impl<'a> Table<'a> {
/// Creates a new [`Table`] widget with the given rows.
///
/// The `rows` parameter is a Vector of [`Row`], this holds the data to be displayed by the
/// table
///
/// # Examples
///
/// ```rust
/// # use ratatui::prelude::*;
/// # use ratatui::widgets::{Table, Row, Cell};
/// let table = Table::new(vec![
/// Row::new(vec![
/// Cell::from("Cell1"),
/// Cell::from("Cell2")
/// ]),
/// Row::new(vec![
/// Cell::from("Cell3"),
/// Cell::from("Cell4")
/// ]),
/// ]);
/// ```
pub fn new<T>(rows: T) -> Self
where
T: IntoIterator<Item = Row<'a>>,