Skip to content

Commit

Permalink
docs(table): add documentation for Table::new() (#471)
Browse files Browse the repository at this point in the history
  • Loading branch information
DreadedHippy authored Sep 5, 2023
1 parent c95a75c commit 232be80
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/widgets/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>>,
Expand Down

0 comments on commit 232be80

Please sign in to comment.