Struct table_to_html::Alignment
source · pub struct Alignment { /* private fields */ }
Expand description
Alignment represent a horizontal and vertical alignment setting for any cell on a Table
.
An alignment strategy can be set by AlignmentStrategy
.
Example
use tabled::{
Table,
settings::{
formatting::AlignmentStrategy,
object::Segment, Alignment, Modify, Style,
}
};
let data = [
["1", "2", "3"],
["Some\nMulti\nLine\nText", "and a line", "here"],
["4", "5", "6"],
];
let mut table = Table::new(&data);
table
.with(Style::modern())
.with(
Modify::new(Segment::all())
.with(Alignment::right())
.with(Alignment::center())
.with(AlignmentStrategy::PerCell)
);
assert_eq!(
table.to_string(),
concat!(
"┌───────┬────────────┬──────┐\n",
"│ 0 │ 1 │ 2 │\n",
"├───────┼────────────┼──────┤\n",
"│ 1 │ 2 │ 3 │\n",
"├───────┼────────────┼──────┤\n",
"│ Some │ and a line │ here │\n",
"│ Multi │ │ │\n",
"│ Line │ │ │\n",
"│ Text │ │ │\n",
"├───────┼────────────┼──────┤\n",
"│ 4 │ 5 │ 6 │\n",
"└───────┴────────────┴──────┘",
),
)
Implementations§
source§impl Alignment
impl Alignment
sourcepub const fn left() -> Alignment
pub const fn left() -> Alignment
Left constructs a horizontal alignment to [AlignmentHorizontal::Left
]
sourcepub const fn right() -> Alignment
pub const fn right() -> Alignment
Right constructs a horizontal alignment to [AlignmentHorizontal::Right
]
Notice
When you use MinWidth
the alignment might not work as you expected.
You could try to apply TrimStrategy
which may help.
sourcepub const fn center() -> Alignment
pub const fn center() -> Alignment
Center constructs a horizontal alignment to [AlignmentHorizontal::Center
]
Notice
When you use MinWidth
the alignment might not work as you expected.
You could try to apply TrimStrategy
which may help.
sourcepub const fn top() -> Alignment
pub const fn top() -> Alignment
Top constructs a vertical alignment to [AlignmentVertical::Top
]
sourcepub const fn bottom() -> Alignment
pub const fn bottom() -> Alignment
Bottom constructs a vertical alignment to [AlignmentVertical::Bottom
]
sourcepub const fn center_vertical() -> Alignment
pub const fn center_vertical() -> Alignment
Center_vertical
constructs a vertical alignment to [AlignmentVertical::Center
]
Trait Implementations§
source§impl<R> CellOption<R, ColoredConfig> for Alignment
impl<R> CellOption<R, ColoredConfig> for Alignment
source§fn change(self, _: &mut R, cfg: &mut ColoredConfig, entity: Entity)
fn change(self, _: &mut R, cfg: &mut ColoredConfig, entity: Entity)
Entity
.source§fn hint_change(&self) -> Option<Entity>
fn hint_change(&self) -> Option<Entity>
TableOption
is going to change table layout. Read moresource§impl Ord for Alignment
impl Ord for Alignment
source§impl PartialEq for Alignment
impl PartialEq for Alignment
source§impl PartialOrd for Alignment
impl PartialOrd for Alignment
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<R, D> TableOption<R, ColoredConfig, D> for Alignment
impl<R, D> TableOption<R, ColoredConfig, D> for Alignment
source§fn change(self, _: &mut R, cfg: &mut ColoredConfig, _: &mut D)
fn change(self, _: &mut R, cfg: &mut ColoredConfig, _: &mut D)
source§fn hint_change(&self) -> Option<Entity>
fn hint_change(&self) -> Option<Entity>
TableOption
is going to change table layout. Read moresource§impl<R, D> TableOption<R, CompactConfig, D> for Alignment
impl<R, D> TableOption<R, CompactConfig, D> for Alignment
source§impl<R, D> TableOption<R, CompactMultilineConfig, D> for Alignment
impl<R, D> TableOption<R, CompactMultilineConfig, D> for Alignment
source§fn change(self, _: &mut R, cfg: &mut CompactMultilineConfig, _: &mut D)
fn change(self, _: &mut R, cfg: &mut CompactMultilineConfig, _: &mut D)
source§fn hint_change(&self) -> Option<Entity>
fn hint_change(&self) -> Option<Entity>
TableOption
is going to change table layout. Read more