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
sourcepub const fn get_horizontal(self) -> Option<AlignmentHorizontal>
pub const fn get_horizontal(self) -> Option<AlignmentHorizontal>
Convert alignment to horizontal.
sourcepub const fn get_vertical(self) -> Option<AlignmentVertical>
pub const fn get_vertical(self) -> Option<AlignmentVertical>
Convert alignment to vertical.
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 From<AlignmentHorizontal> for Alignment
impl From<AlignmentHorizontal> for Alignment
source§fn from(value: AlignmentHorizontal) -> Alignment
fn from(value: AlignmentHorizontal) -> Alignment
source§impl From<AlignmentVertical> for Alignment
impl From<AlignmentVertical> for Alignment
source§fn from(value: AlignmentVertical) -> Alignment
fn from(value: AlignmentVertical) -> Alignment
source§impl Ord for Alignment
impl Ord for Alignment
source§impl PartialOrd for Alignment
impl PartialOrd for Alignment
source§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§fn change(self, _: &mut R, cfg: &mut CompactConfig, _: &mut D)
fn change(self, _: &mut R, cfg: &mut CompactConfig, _: &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, 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 moreimpl Copy for Alignment
impl Eq for Alignment
impl StructuralPartialEq for Alignment
Auto Trait Implementations§
impl Freeze for Alignment
impl RefUnwindSafe for Alignment
impl Send for Alignment
impl Sync for Alignment
impl Unpin for Alignment
impl UnwindSafe for Alignment
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)