1//! This module contains a [`Span`] settings, it helps to
2//! make a cell take more space then it generally takes.
3//!
4//! # Example
5//!
6//! ```
7//! use tabled::{settings::{Span, Modify}, Table};
8//!
9//! let data = [[1, 2, 3], [4, 5, 6]];
10//!
11//! let table = Table::new(data)
12//! .with(Modify::new((2, 0)).with(Span::column(2)))
13//! .with(Modify::new((0, 1)).with(Span::column(2)))
14//! .to_string();
15//!
16//! assert_eq!(
17//! table,
18//! concat!(
19//! "+---+---+---+\n",
20//! "| 0 | 1 |\n",
21//! "+---+---+---+\n",
22//! "| 1 | 2 | 3 |\n",
23//! "+---+---+---+\n",
24//! "| 4 | 6 |\n",
25//! "+---+---+---+",
26//! )
27//! )
28//! ```
29
30mod column;
31mod row;
32
33pub use column::ColumnSpan;
34pub use row::RowSpan;
35
36/// Span represent a horizontal/column span setting for any cell on a [`Table`].
37///
38/// It will be ignored if:
39/// - cell position is out of scope
40/// - size is bigger then the total number of columns.
41/// - size is bigger then the total number of rows.
42///
43/// ```rust,no_run
44/// # use tabled::{Table, settings::{Style, Span, Modify, object::Columns}};
45/// # let data: Vec<&'static str> = Vec::new();
46/// let table = Table::new(&data)
47/// .with(Modify::new(Columns::single(0)).with(Span::column(2)));
48/// ```
49///
50/// [`Table`]: crate::Table
51#[derive(Debug)]
52pub struct Span;
53
54impl Span {
55 /// New constructs a horizontal/column [`Span`].
56 ///
57 /// If size is bigger then the total number of columns it will be ignored.
58 pub fn column(size: usize) -> ColumnSpan {
59 ColumnSpan::new(size)
60 }
61
62 /// New constructs a vertical/row [`Span`].
63 ///
64 /// If size is bigger then the total number of rows it will be ignored.
65 pub fn row(size: usize) -> RowSpan {
66 RowSpan::new(size)
67 }
68}
69