Repository: zhiburt/tabled
Pull request #434 (2024-10-26 21:49:26)

More refactorings


Patch:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index e0f4fb1..6536e78 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -120,7 +120,7 @@ jobs:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v3
-      - uses: dtolnay/rust-toolchain@1.62.1
+      - uses: dtolnay/rust-toolchain@1.66.0
       - run: cargo build --manifest-path=./tabled/Cargo.toml --all-features
 
   fmt:
diff --git a/papergrid/src/config/border.rs b/papergrid/src/config/border.rs
index c981807..27b98c0 100644
--- a/papergrid/src/config/border.rs
+++ b/papergrid/src/config/border.rs
@@ -123,6 +123,23 @@ impl<T> Border<T> {
             || self.right_top_corner.is_some()
             || self.right_bottom_corner.is_some()
     }
+
+    /// Converts a border with a given function.
+    pub fn map<F, T1>(self, f: F) -> Border<T1>
+    where
+        F: Fn(T) -> T1,
+    {
+        Border {
+            top: self.top.map(&f),
+            bottom: self.bottom.map(&f),
+            left: self.left.map(&f),
+            right: self.right.map(&f),
+            left_top_corner: self.left_top_corner.map(&f),
+            left_bottom_corner: self.left_bottom_corner.map(&f),
+            right_top_corner: self.right_top_corner.map(&f),
+            right_bottom_corner: self.right_bottom_corner.map(&f),
+        }
+    }
 }
 
 impl<T: Copy> Border<T> {
diff --git a/papergrid/src/config/borders.rs b/papergrid/src/config/borders.rs
index ef369ed..2363276 100644
--- a/papergrid/src/config/borders.rs
+++ b/papergrid/src/config/borders.rs
@@ -173,4 +173,28 @@ impl<T> Borders<T> {
             vertical: self.vertical.map(Into::into),
         }
     }
+
+    /// Converts borders with a given function.
+    pub fn map<F, T1>(self, f: F) -> Borders<T1>
+    where
+        F: Fn(T) -> T1,
+    {
+        Borders {
+            left: self.left.map(&f),
+            right: self.right.map(&f),
+            top: self.top.map(&f),
+            bottom: self.bottom.map(&f),
+            bottom_intersection: self.bottom_intersection.map(&f),
+            bottom_left: self.bottom_left.map(&f),
+            bottom_right: self.bottom_right.map(&f),
+            horizontal: self.horizontal.map(&f),
+            intersection: self.intersection.map(&f),
+            left_intersection: self.left_intersection.map(&f),
+            right_intersection: self.right_intersection.map(&f),
+            top_intersection: self.top_intersection.map(&f),
+            top_left: self.top_left.map(&f),
+            top_right: self.top_right.map(&f),
+            vertical: self.vertical.map(&f),
+        }
+    }
 }
diff --git a/papergrid/src/config/entity.rs b/papergrid/src/config/entity.rs
index bcdafcf..40939bf 100644
--- a/papergrid/src/config/entity.rs
+++ b/papergrid/src/config/entity.rs
@@ -37,13 +37,7 @@ pub enum Entity {
 impl Entity {
     /// Iterate over cells which are covered via the [`Entity`].
     pub fn iter(&self, count_rows: usize, count_cols: usize) -> EntityIterator {
-        EntityIterator {
-            entity: *self,
-            count_rows,
-            count_cols,
-            i: 0,
-            j: 0,
-        }
+        EntityIterator::new(*self, count_rows, count_cols)
     }
 }
 
@@ -65,6 +59,18 @@ pub struct EntityIterator {
     j: usize,
 }
 
+impl EntityIterator {
+    fn new(entity: Entity, count_rows: usize, count_cols: usize) -> Self {
+        Self {
+            entity,
+            count_rows,
+            count_cols,
+            i: 0,
+            j: 0,
+        }
+    }
+}
+
 impl Iterator for EntityIterator {
     type Item = Position;
 
diff --git a/papergrid/src/config/formatting.rs b/papergrid/src/config/formatting.rs
index 6ad6b6c..b863761 100644
--- a/papergrid/src/config/formatting.rs
+++ b/papergrid/src/config/formatting.rs
@@ -1,4 +1,4 @@
-/// Formatting represent a logic of formatting of a cell.
+/// Formatting represent a logic of formatting of a cell text.
 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
 pub struct Formatting {
     /// An setting to allow horizontal trim.
diff --git a/papergrid/src/config/sides.rs b/papergrid/src/config/sides.rs
index 214145e..25b5bcc 100644
--- a/papergrid/src/config/sides.rs
+++ b/papergrid/src/config/sides.rs
@@ -42,4 +42,17 @@ impl<T> Sides<T> {
             self.bottom.into(),
         )
     }
+
+    /// Converts all sides with a given function.
+    pub fn map<F, T1>(self, f: F) -> Sides<T1>
+    where
+        F: Fn(T) -> T1,
+    {
+        Sides::new(
+            (f)(self.left),
+            (f)(self.right),
+            (f)(self.top),
+            (f)(self.bottom),
+        )
+    }
 }
diff --git a/papergrid/src/grid/iterable.rs b/papergrid/src/grid/iterable.rs
index 2e8372f..e97fad7 100644
--- a/papergrid/src/grid/iterable.rs
+++ b/papergrid/src/grid/iterable.rs
@@ -1313,40 +1313,8 @@ fn text_width(text: &str, trim: bool) -> usize {
 
 #[cfg(test)]
 mod tests {
-    // use crate::util::string_width;
-
     use super::*;
 
-    // #[test]
-    // fn horizontal_alignment_test() {
-    //     use std::fmt;
-
-    //     struct F<'a>(&'a str, AlignmentHorizontal, usize);
-
-    //     impl fmt::Display for F<'_> {
-    //         fn fmt(&self, f: &mut impl fmt::Write) -> fmt::Result {
-    //             let (left, right) = calculate_indent(self.1, string_width(self.0), self.2);
-    //             print_text_formatted(f, &self.0, 4, Option::<&AnsiColor<'_>>::None)
-    //         }
-    //     }
-
-    //     assert_eq!(F("AAA", AlignmentHorizontal::Right, 4).to_string(), " AAA");
-    //     assert_eq!(F("AAA", AlignmentHorizontal::Left, 4).to_string(), "AAA ");
-    //     assert_eq!(F("AAA", AlignmentHorizontal::Center, 4).to_string(), "AAA ");
-    //     assert_eq!(F("🎩", AlignmentHorizontal::Center, 4).to_string(), " 🎩 ");
-    //     assert_eq!(F("🎩", AlignmentHorizontal::Center, 3).to_string(), "🎩 ");
-
-    //     #[cfg(feature = "ansi")]
-    //     {
-    //         use owo_colors::OwoColorize;
-    //         let text = "Colored Text".red().to_string();
-    //         assert_eq!(
-    //             F(&text, AlignmentHorizontal::Center, 15).to_string(),
-    //             format!(" {}  ", text)
-    //         );
-    //     }
-    // }
-
     #[test]
     fn vertical_alignment_test() {
         use AlignmentVertical::*;
diff --git a/papergrid/src/grid/peekable.rs b/papergrid/src/grid/peekable.rs
index 27b5a47..8f47841 100644
--- a/papergrid/src/grid/peekable.rs
+++ b/papergrid/src/grid/peekable.rs
@@ -271,8 +271,8 @@ mod grid_basic {
     where
         F: fmt::Write,
     {
-        let intersection = match cfg.get_intersection(pos, (shape.count_rows, shape.count_columns))
-        {
+        let intersection = cfg.get_intersection(pos, (shape.count_rows, shape.count_columns));
+        let intersection = match intersection {
             Some(c) => c,
             None => return Ok(()),
         };
diff --git a/papergrid/src/util/string.rs b/papergrid/src/util/string.rs
index 8eada2f..23365b9 100644
--- a/papergrid/src/util/string.rs
+++ b/papergrid/src/util/string.rs
@@ -52,7 +52,17 @@ pub fn get_char_width(c: char) -> usize {
 
 /// Returns a string width (accouting all characters).
 pub fn get_string_width(text: &str) -> usize {
-    unicode_width::UnicodeWidthStr::width(text.replace(|c| c < ' ', "").as_str())
+    #[cfg(feature = "std")]
+    {
+        let text = text.replace(|c| c < ' ', "");
+        unicode_width::UnicodeWidthStr::width(text.as_str())
+    }
+
+    #[cfg(not(feature = "std"))]
+    {
+        // todo: make sure it's allright
+        unicode_width::UnicodeWidthStr::width(text)
+    }
 }
 
 /// Calculates a number of lines.
diff --git a/tabled/examples/nested_table_3.rs b/tabled/examples/nested_table_3.rs
index 00eec47..debb96a 100644
--- a/tabled/examples/nested_table_3.rs
+++ b/tabled/examples/nested_table_3.rs
@@ -7,7 +7,7 @@ use tabled::{
     settings::{
         object::Rows,
         style::{BorderSpanCorrection, Style},
-        Alignment, Border, Extract, Highlight, Padding, Panel,
+        Alignment, Extract, Highlight, Padding, Panel,
     },
     Table, Tabled,
 };
@@ -54,7 +54,7 @@ fn main() {
         .with(Style::ascii().remove_horizontal())
         .modify(Rows::new(1..), Padding::new(1, 1, 1, 0))
         .with(Alignment::center())
-        .with(Highlight::border(Rows::first(), Border::filled('*')));
+        .with(Highlight::outline(Rows::first(), '*'));
 
     println!("{welcome_table}");
 }
diff --git a/tabled/src/builder/index_builder.rs b/tabled/src/builder/index_builder.rs
index 3422cec..5d2dbfe 100644
--- a/tabled/src/builder/index_builder.rs
+++ b/tabled/src/builder/index_builder.rs
@@ -203,7 +203,7 @@ impl IndexBuilder {
         std::mem::swap(&mut self.index, &mut columns);
 
         let count_columns = columns.len();
-        make_rows_columns(&mut self.data, self.index.len());
+        rotate_vector(&mut self.data, self.index.len());
 
         self.data.insert(0, columns);
 
@@ -280,35 +280,22 @@ fn build_range_index(n: usize) -> Vec<Text<String>> {
     (0..n).map(|i| i.to_string()).map(Text::new).collect()
 }
 
-fn get_column<T>(v: &mut [Vec<T>], col: usize) -> Vec<T>
+// note: Pretty heavy operation.
+fn rotate_vector<T>(rows: &mut Vec<Vec<T>>, count_columns: usize)
 where
-    T: Default,
+    T: Default + Clone,
 {
-    let mut column = Vec::with_capacity(v.len());
-    for row in v.iter_mut() {
-        let value = row.remove(col);
-        column.push(value);
-    }
-
-    column
-}
-
-// todo: Seems like can be hugely simplified.
-fn make_rows_columns<T>(v: &mut Vec<Vec<T>>, count_columns: usize)
-where
-    T: Default,
-{
-    let mut columns = Vec::with_capacity(count_columns);
-    for _ in 0..count_columns {
-        let column = get_column(v, 0);
-        columns.push(column);
+    let count_rows = rows.len();
+    let mut columns = vec![vec![T::default(); count_rows]; count_columns];
+    for col in 0..count_columns {
+        for (row, data) in rows.iter_mut().enumerate() {
+            let value = data.pop().expect("expected to be controlled");
+            let col = count_columns - col - 1;
+            columns[col][row] = value;
+        }
     }
 
-    v.clear();
-
-    for column in columns {
-        v.push(column);
-    }
+    *rows = columns;
 }
 
 fn insert_column<T: Default>(v: &mut [Vec<T>], mut column: Vec<T>, col: usize) {
@@ -317,3 +304,16 @@ fn insert_column<T: Default>(v: &mut [Vec<T>], mut column: Vec<T>, col: usize) {
         row.insert(col, value);
     }
 }
+
+fn get_column<T>(v: &mut [Vec<T>], col: usize) -> Vec<T>
+where
+    T: Default,
+{
+    let mut column = Vec::with_capacity(v.len());
+    for row in v.iter_mut() {
+        let value = row.remove(col);
+        column.push(value);
+    }
+
+    column
+}
diff --git a/tabled/src/grid/colored_config.rs b/tabled/src/grid/config/colored_config.rs
similarity index 100%
rename from tabled/src/grid/colored_config.rs
rename to tabled/src/grid/config/colored_config.rs
diff --git a/tabled/src/grid/config/compact_config.rs b/tabled/src/grid/config/compact_config.rs
new file mode 100644
index 0000000..77ea0a4
--- /dev/null
+++ b/tabled/src/grid/config/compact_config.rs
@@ -0,0 +1,1 @@
+pub use papergrid::config::compact::CompactConfig;
diff --git a/tabled/src/grid/compact_multiline_config.rs b/tabled/src/grid/config/compact_multiline_config.rs
similarity index 100%
rename from tabled/src/grid/compact_multiline_config.rs
rename to tabled/src/grid/config/compact_multiline_config.rs
diff --git a/tabled/src/grid/config/mod.rs b/tabled/src/grid/config/mod.rs
new file mode 100644
index 0000000..eced851
--- /dev/null
+++ b/tabled/src/grid/config/mod.rs
@@ -0,0 +1,26 @@
+//! Module contains a list of configs for varios tables/grids.
+
+#[cfg(feature = "std")]
+mod colored_config;
+
+#[cfg(feature = "std")]
+mod spanned_config;
+
+mod compact_config;
+mod compact_multiline_config;
+
+pub use papergrid::config::{
+    AlignmentHorizontal, AlignmentVertical, Border, Borders, Entity, EntityIterator, Formatting,
+    HorizontalLine, Indent, Position, Sides, VerticalLine,
+};
+
+#[cfg(feature = "std")]
+#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
+pub use spanned_config::{EntityMap, Offset, SpannedConfig};
+
+#[cfg(feature = "std")]
+#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
+pub use colored_config::{ColorMap, ColoredConfig};
+
+pub use compact_config::CompactConfig;
+pub use compact_multiline_config::CompactMultilineConfig;
diff --git a/tabled/src/grid/config/spanned_config.rs b/tabled/src/grid/config/spanned_config.rs
new file mode 100644
index 0000000..1c5b138
--- /dev/null
+++ b/tabled/src/grid/config/spanned_config.rs
@@ -0,0 +1,1 @@
+pub use papergrid::config::spanned::{EntityMap, Offset, SpannedConfig};
diff --git a/tabled/src/grid/mod.rs b/tabled/src/grid/mod.rs
index 7ea92d2..7c353f0 100644
--- a/tabled/src/grid/mod.rs
+++ b/tabled/src/grid/mod.rs
@@ -4,11 +4,8 @@
 //!
 //! [`TableOption`]: crate::settings::TableOption
 //! [`CellOption`]: crate::settings::CellOption
-#[cfg(feature = "std")]
-mod colored_config;
-
-mod compact_multiline_config;
 
+pub mod config;
 pub mod dimension;
 pub mod records;
 
@@ -16,25 +13,6 @@ pub use papergrid::ansi;
 pub use papergrid::colors;
 pub use papergrid::util;
 
-pub mod config {
-    //! Module contains a list of configs for varios tables/grids.
-
-    pub use papergrid::config::{
-        compact::CompactConfig, AlignmentHorizontal, AlignmentVertical, Border, Borders, Entity,
-        EntityIterator, Formatting, HorizontalLine, Indent, Position, Sides, VerticalLine,
-    };
-
-    #[cfg(feature = "std")]
-    #[cfg_attr(docsrs, doc(cfg(feature = "std")))]
-    pub use papergrid::config::spanned::{EntityMap, Offset, SpannedConfig};
-
-    #[cfg(feature = "std")]
-    #[cfg_attr(docsrs, doc(cfg(feature = "std")))]
-    pub use super::colored_config::{ColorMap, ColoredConfig};
-
-    pub use super::compact_multiline_config::CompactMultilineConfig;
-}
-
 pub use papergrid::grid::compact::CompactGrid;
 
 #[cfg(feature = "std")]
diff --git a/tabled/src/settings/alignment/mod.rs b/tabled/src/settings/alignment/mod.rs
index 1603c64..d675e23 100644
--- a/tabled/src/settings/alignment/mod.rs
+++ b/tabled/src/settings/alignment/mod.rs
@@ -138,7 +138,7 @@ impl Alignment {
     }
 
     /// Convert alignment to horizontal.
-    pub const fn get_horizontal(self) -> Option<AlignmentHorizontal> {
+    pub const fn as_horizontal(self) -> Option<AlignmentHorizontal> {
         match self.inner {
             Horizontal(alignment) => Some(alignment),
             Vertical(_) => None,
@@ -146,7 +146,7 @@ impl Alignment {
     }
 
     /// Convert alignment to vertical.
-    pub const fn get_vertical(self) -> Option<AlignmentVertical> {
+    pub const fn as_vertical(self) -> Option<AlignmentVertical> {
         match self.inner {
             Horizontal(_) => None,
             Vertical(alignment) => Some(alignment),
diff --git a/tabled/src/settings/color/mod.rs b/tabled/src/settings/color/mod.rs
index f482e63..f7b084f 100644
--- a/tabled/src/settings/color/mod.rs
+++ b/tabled/src/settings/color/mod.rs
@@ -225,6 +225,14 @@ impl Color {
         }
     }
 
+    /// Tries to get a static value of the color.
+    pub fn as_ansi_str(&self) -> Option<StaticColor<'static>> {
+        match self.inner {
+            ColorInner::Static(value) => Some(value),
+            ColorInner::Buf(_) => None,
+        }
+    }
+
     /// Parses the string,
     ///
     /// # Panics
@@ -265,6 +273,14 @@ impl From<ANSIBuf> for Color {
     }
 }
 
+impl From<StaticColor<'static>> for Color {
+    fn from(color: StaticColor<'static>) -> Self {
+        Self {
+            inner: ColorInner::Static(color),
+        }
+    }
+}
+
 impl BitOr for Color {
     type Output = Color;
 
diff --git a/tabled/src/settings/highlight/mod.rs b/tabled/src/settings/highlight/mod.rs
index f3bc529..89aff0c 100644
--- a/tabled/src/settings/highlight/mod.rs
+++ b/tabled/src/settings/highlight/mod.rs
@@ -16,40 +16,9 @@ use crate::{
 
 /// Highlight modifies a table style by changing a border of a target [`Table`] segment.
 ///
-/// # Example
-///
-/// ```
-/// use tabled::{
-///     Table,
-///     settings::{Highlight, Border, Style, object::Segment}
-/// };
-///
-/// let data = [
-///     ("ELF", "Extensible Linking Format", true),
-///     ("DWARF", "", true),
-///     ("PE", "Portable Executable", false),
-/// ];
+/// It basically highlights outer border of a given segment.
 ///
-/// let table = Table::new(data.iter().enumerate())
-///                .with(Style::markdown())
-///                .with(Highlight::border(Segment::all(), Border::new().set_top('^').set_bottom('v')))
-///                .to_string();
-///
-/// assert_eq!(
-///     table,
-///     concat!(
-///         " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",
-///         "| usize | &str  | &str                      | bool  |\n",
-///         "|-------|-------|---------------------------|-------|\n",
-///         "| 0     | ELF   | Extensible Linking Format | true  |\n",
-///         "| 1     | DWARF |                           | true  |\n",
-///         "| 2     | PE    | Portable Executable       | false |\n",
-///         " vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv ",
-///     ),
-/// );
-/// ```
-///
-/// It's possible to use [`Highlight`] for many kinds of figures.
+/// # Example
 ///
 /// ```
 /// use tabled::{
@@ -68,11 +37,9 @@ use crate::{
 ///
 /// let table = Table::new(data.iter().enumerate())
 ///                .with(Style::markdown())
-///                .with(Highlight::border(Segment::all().not((0,0).and((1, 0)).and((0, 1)).and((0, 3))), Border::filled('*')))
+///                .with(Highlight::outline(Segment::all().not((0,0).and((1, 0)).and((0, 1)).and((0, 3))), '*'))
 ///                .to_string();
 ///
-/// println!("{}", table);
-///
 /// assert_eq!(
 ///     table,
 ///     concat!(
@@ -105,28 +72,11 @@ enum HighlightInner {
     ColoredBorder(GridBorder<char>, GridBorder<ANSIBuf>),
 }
 
-// todo: Docs testss
-
-// todo: Move colors to Highlight itself
-// todo: Maybe add a default Border and set ask for a char -> Highlight::new(target).border().outline().color().outline_color()
-
-// todo: Add BorderColor.
-
 impl<O> Highlight<O> {
-    /// Build a new instance of [`Highlight`]
+    /// Build a new instance of [`Highlight`],
+    /// highlighting by a color, while preserving existing border.
     ///
     /// BE AWARE: if target exceeds boundaries it may panic.
-    pub const fn border<T, B, L, R>(target: O, border: Border<T, B, L, R>) -> Self {
-        Self {
-            target,
-            border: HighlightInner::Border(border.into_inner()),
-        }
-    }
-
-    /// Build a new instance of [`Highlight`]
-    ///
-    /// BE AWARE: if target exceeds boundaries it may panic.
-    // #[cfg(feature = "ansi")]
     pub fn color(target: O, border: BorderColor) -> Self {
         let color = border.into_inner();
         let color = color.convert();
@@ -137,29 +87,36 @@ impl<O> Highlight<O> {
         }
     }
 
-    /// Build a new instance of [`Highlight`]
+    /// Build a new instance of [`Highlight`],
+    /// highlighting by a character.
     ///
     /// BE AWARE: if target exceeds boundaries it may panic.
     pub const fn outline(target: O, c: char) -> Self {
-        Self::border(target, Border::filled(c))
+        Self::new(target, Border::filled(c))
     }
 
-    /// Build a new instance of [`Highlight`]
+    /// Build a new instance of [`Highlight`],
+    /// highlighting by a color and a given character for a border.
     ///
     /// BE AWARE: if target exceeds boundaries it may panic.
-    pub fn colored_outline<T, B, L, R>(target: O, c: char, color: Color) -> Self {
-        Self::colored_border(target, Border::filled(c), BorderColor::filled(color))
+    pub fn outline_colored<T, B, L, R>(target: O, c: char, color: Color) -> Self {
+        Self::colored(target, Border::filled(c), BorderColor::filled(color))
     }
 
     /// Build a new instance of [`Highlight`]
     ///
     /// BE AWARE: if target exceeds boundaries it may panic.
-    // #[cfg(feature = "ansi")]
-    pub fn colored_border<T, B, L, R>(
-        target: O,
-        border: Border<T, B, L, R>,
-        color: BorderColor,
-    ) -> Self {
+    pub const fn new<T, B, L, R>(target: O, border: Border<T, B, L, R>) -> Self {
+        Self {
+            target,
+            border: HighlightInner::Border(border.into_inner()),
+        }
+    }
+
+    /// Build a new instance of [`Highlight`] colored.
+    ///
+    /// BE AWARE: if target exceeds boundaries it may panic.
+    pub fn colored<T, B, L, R>(target: O, border: Border<T, B, L, R>, color: BorderColor) -> Self {
         let border = border.into_inner();
         let color = color.into_inner().convert();
 
@@ -182,21 +139,17 @@ where
         let cells = self.target.cells(records);
         let segments = split_segments(cells, count_rows, count_cols);
 
-        match self.border {
-            HighlightInner::Border(border) => {
-                for sector in segments {
-                    set_border(cfg, &sector, border);
+        for sector in segments {
+            match &self.border {
+                HighlightInner::Border(border) => {
+                    set_border(cfg, &sector, *border);
                 }
-            }
-            HighlightInner::Color(color) => {
-                for sector in segments {
-                    set_border_color(cfg, &sector, &color);
+                HighlightInner::Color(color) => {
+                    set_border_color(cfg, &sector, color);
                 }
-            }
-            HighlightInner::ColoredBorder(border, color) => {
-                for sector in segments {
-                    set_border(cfg, &sector, border);
-                    set_border_color(cfg, &sector, &color);
+                HighlightInner::ColoredBorder(border, color) => {
+                    set_border(cfg, &sector, *border);
+                    set_border_color(cfg, &sector, color);
                 }
             }
         }
@@ -209,7 +162,7 @@ where
 
 fn set_border_color(
     cfg: &mut SpannedConfig,
-    sector: &HashSet<(usize, usize)>,
+    sector: &HashSet<Position>,
     border: &GridBorder<ANSIBuf>,
 ) {
     if sector.is_empty() {
@@ -226,8 +179,8 @@ fn split_segments(
     cells: impl Iterator<Item = Entity>,
     count_rows: usize,
     count_cols: usize,
-) -> Vec<HashSet<(usize, usize)>> {
-    let mut segments: Vec<HashSet<(usize, usize)>> = Vec::new();
+) -> Vec<HashSet<Position>> {
+    let mut segments: Vec<HashSet<Position>> = Vec::new();
     for entity in cells {
         for cell in entity.iter(count_rows, count_cols) {
             let found_segment = segments
@@ -247,7 +200,7 @@ fn split_segments(
         }
     }
 
-    let mut squashed_segments: Vec<HashSet<(usize, usize)>> = Vec::new();
+    let mut squashed_segments: Vec<HashSet<Position>> = Vec::new();
     while !segments.is_empty() {
         let mut segment = segments.remove(0);
 
@@ -267,7 +220,7 @@ fn split_segments(
     squashed_segments
 }
 
-fn is_cell_connected((row1, col1): (usize, usize), (row2, col2): (usize, usize)) -> bool {
+fn is_cell_connected((row1, col1): Position, (row2, col2): Position) -> bool {
     if col1 == col2 && row1 == row2 + 1 {
         return true;
     }
@@ -287,10 +240,7 @@ fn is_cell_connected((row1, col1): (usize, usize), (row2, col2): (usize, usize))
     false
 }
 
-fn is_segment_connected(
-    segment1: &HashSet<(usize, usize)>,
-    segment2: &HashSet<(usize, usize)>,
-) -> bool {
+fn is_segment_connected(segment1: &HashSet<Position>, segment2: &HashSet<Position>) -> bool {
     for &cell1 in segment1.iter() {
         for &cell2 in segment2.iter() {
             if is_cell_connected(cell1, cell2) {
@@ -302,7 +252,7 @@ fn is_segment_connected(
     false
 }
 
-fn set_border(cfg: &mut SpannedConfig, sector: &HashSet<(usize, usize)>, border: GridBorder<char>) {
+fn set_border(cfg: &mut SpannedConfig, sector: &HashSet<Position>, border: GridBorder<char>) {
     if sector.is_empty() {
         return;
     }
@@ -314,7 +264,7 @@ fn set_border(cfg: &mut SpannedConfig, sector: &HashSet<(usize, usize)>, border:
 }
 
 fn build_cell_border<T>(
-    sector: &HashSet<(usize, usize)>,
+    sector: &HashSet<Position>,
     (row, col): Position,
     border: &GridBorder<T>,
 ) -> GridBorder<T>
@@ -445,63 +395,38 @@ where
     cell_border
 }
 
-fn cell_has_top_neighbor(sector: &HashSet<(usize, usize)>, row: usize, col: usize) -> bool {
+fn cell_has_top_neighbor(sector: &HashSet<Position>, row: usize, col: usize) -> bool {
     row > 0 && sector.contains(&(row - 1, col))
 }
 
-fn cell_has_bottom_neighbor(sector: &HashSet<(usize, usize)>, row: usize, col: usize) -> bool {
+fn cell_has_bottom_neighbor(sector: &HashSet<Position>, row: usize, col: usize) -> bool {
     sector.contains(&(row + 1, col))
 }
 
-fn cell_has_left_neighbor(sector: &HashSet<(usize, usize)>, row: usize, col: usize) -> bool {
+fn cell_has_left_neighbor(sector: &HashSet<Position>, row: usize, col: usize) -> bool {
     col > 0 && sector.contains(&(row, col - 1))
 }
 
-fn cell_has_right_neighbor(sector: &HashSet<(usize, usize)>, row: usize, col: usize) -> bool {
+fn cell_has_right_neighbor(sector: &HashSet<Position>, row: usize, col: usize) -> bool {
     sector.contains(&(row, col + 1))
 }
 
-fn is_there_left_top_cell(sector: &HashSet<(usize, usize)>, row: usize, col: usize) -> bool {
+fn is_there_left_top_cell(sector: &HashSet<Position>, row: usize, col: usize) -> bool {
     row > 0 && col > 0 && sector.contains(&(row - 1, col - 1))
 }
 
-fn is_there_right_top_cell(sector: &HashSet<(usize, usize)>, row: usize, col: usize) -> bool {
+fn is_there_right_top_cell(sector: &HashSet<Position>, row: usize, col: usize) -> bool {
     row > 0 && sector.contains(&(row - 1, col + 1))
 }
 
-fn is_there_left_bottom_cell(sector: &HashSet<(usize, usize)>, row: usize, col: usize) -> bool {
+fn is_there_left_bottom_cell(sector: &HashSet<Position>, row: usize, col: usize) -> bool {
     col > 0 && sector.contains(&(row + 1, col - 1))
 }
 
-fn is_there_right_bottom_cell(sector: &HashSet<(usize, usize)>, row: usize, col: usize) -> bool {
+fn is_there_right_bottom_cell(sector: &HashSet<Position>, row: usize, col: usize) -> bool {
     sector.contains(&(row + 1, col + 1))
 }
 
-// fn split_tuple_border<A, B>(border: GridBorder<(A, B)>) -> (GridBorder<A>, GridBorder<B>) {
-//     macro_rules! set_border {
-//         ($border1:expr, $border2:expr => $symbl:expr) => {
-//             if let Some((x1, x2)) = $symbl {
-//                 $border1 = Some(x1);
-//                 $border2 = Some(x2);
-//             }
-//         };
-//     }
-
-//     let mut a = GridBorder::empty();
-//     let mut b = GridBorder::empty();
-
-//     set_border!(a.bottom, b.bottom => border.bottom);
-//     set_border!(a.top, b.top => border.top);
-//     set_border!(a.left, b.left => border.left);
-//     set_border!(a.left_top_corner, b.left_top_corner => border.left_top_corner);
-//     set_border!(a.left_bottom_corner, b.left_bottom_corner => border.left_bottom_corner);
-//     set_border!(a.right, b.right => border.right);
-//     set_border!(a.right_top_corner, b.right_top_corner => border.right_top_corner);
-//     set_border!(a.right_bottom_corner, b.right_bottom_corner => border.right_bottom_corner);
-
-//     (a, b)
-// }
-
 #[cfg(test)]
 mod tests {
     use super::*;
diff --git a/tabled/src/settings/margin/mod.rs b/tabled/src/settings/margin/mod.rs
index 32e6bb9..7357c42 100644
--- a/tabled/src/settings/margin/mod.rs
+++ b/tabled/src/settings/margin/mod.rs
@@ -81,6 +81,18 @@ impl Margin {
     }
 }
 
+impl From<Margin> for Sides<Indent> {
+    fn from(value: Margin) -> Self {
+        value.indent
+    }
+}
+
+impl From<Sides<Indent>> for Margin {
+    fn from(indent: Sides<Indent>) -> Self {
+        Self { indent }
+    }
+}
+
 #[cfg(feature = "std")]
 impl<R, D> TableOption<R, ColoredConfig, D> for Margin {
     fn change(self, _: &mut R, cfg: &mut ColoredConfig, _: &mut D) {
diff --git a/tabled/src/settings/padding_color/mod.rs b/tabled/src/settings/padding_color/mod.rs
index 4331c08..dfae51f 100644
--- a/tabled/src/settings/padding_color/mod.rs
+++ b/tabled/src/settings/padding_color/mod.rs
@@ -96,6 +96,18 @@ impl PaddingColor<ANSIStr<'static>> {
     }
 }
 
+impl<C> From<PaddingColor<C>> for Sides<C> {
+    fn from(value: PaddingColor<C>) -> Self {
+        value.colors
+    }
+}
+
+impl<C> From<Sides<C>> for PaddingColor<C> {
+    fn from(colors: Sides<C>) -> Self {
+        Self { colors }
+    }
+}
+
 #[cfg(feature = "std")]
 impl<R, C> CellOption<R, ColoredConfig> for PaddingColor<C>
 where
diff --git a/tabled/src/settings/themes/layout.rs b/tabled/src/settings/themes/layout.rs
index 7ccba3d..9537f62 100644
--- a/tabled/src/settings/themes/layout.rs
+++ b/tabled/src/settings/themes/layout.rs
@@ -51,7 +51,7 @@ where
 }
 
 const fn convert_orientation(position: Alignment) -> HeadPosition {
-    match (position.get_horizontal(), position.get_vertical()) {
+    match (position.as_horizontal(), position.as_vertical()) {
         (None, Some(AlignmentVertical::Top)) => HeadPosition::Top,
         (None, Some(AlignmentVertical::Bottom)) => HeadPosition::Bottom,
         (Some(AlignmentHorizontal::Left), None) => HeadPosition::Left,
diff --git a/tabled/src/settings/themes/theme.rs b/tabled/src/settings/themes/theme.rs
index 95ddbda..a59492c 100644
--- a/tabled/src/settings/themes/theme.rs
+++ b/tabled/src/settings/themes/theme.rs
@@ -10,7 +10,6 @@
 // IMHO 2
 
 use std::collections::HashMap;
-use std::iter::FromIterator;
 
 use crate::{
     grid::config::{
@@ -244,12 +243,15 @@ impl Theme {
     {
         let vertical = vertical.into();
 
-        match &mut self.lines_verticals {
-            Some(verticals) => {
-                let _ = verticals.insert(line, vertical);
+        let verticals = match &mut self.lines_verticals {
+            Some(verticals) => verticals,
+            None => {
+                self.lines_verticals = Some(HashMap::with_capacity(1));
+                self.lines_verticals.as_mut().expect("checked")
             }
-            None => self.lines_verticals = Some(HashMap::from_iter([(line, vertical)])),
-        }
+        };
+
+        let _ = verticals.insert(line, vertical);
     }
 
     /// Insert a horizontal line to a specific row location.
@@ -259,26 +261,34 @@ impl Theme {
     {
         let horizontal = horizontal.into();
 
-        match &mut self.lines_horizontals {
-            Some(horizontals) => {
-                let _ = horizontals.insert(line, horizontal);
+        let horizontals = match &mut self.lines_horizontals {
+            Some(horizontals) => horizontals,
+            None => {
+                self.lines_horizontals = Some(HashMap::with_capacity(1));
+                self.lines_horizontals.as_mut().expect("checked")
             }
-            None => self.lines_horizontals = Some(HashMap::from_iter([(line, horizontal)])),
-        }
+        };
+
+        let _ = horizontals.insert(line, horizontal);
     }
 
     /// Get a vertical line at the row if any set.
     pub fn get_vertical_line(&self, column: usize) -> Option<&VerticalLine<char>> {
-        self.lines_verticals
-            .as_ref()
-            .and_then(|lines| lines.get(&column))
+        self.lines_verticals.as_ref().and_then(|m| m.get(&column))
     }
 
     /// Get a horizontal line at the row if any set.
     pub fn get_horizontal_line(&self, row: usize) -> Option<&HorizontalLine<char>> {
-        self.lines_horizontals
-            .as_ref()
-            .and_then(|list| list.get(&row))
+        let line = self.lines_horizontals.as_ref().and_then(|m| m.get(&row));
+        if line.is_some() {
+            return line;
+        }
+
+        if row == 1 && self.lines_horizontal1.is_some() {
+            return self.lines_horizontal1.as_ref();
+        }
+
+        None
     }
 
     /// Verifies if borders has left line set on the frame.
@@ -314,23 +324,29 @@ impl Theme {
     const fn gen(
         chars: Borders<char>,
         colors: Borders<Color>,
-        lines_horizontals: Option<HashMap<usize, HorizontalLine<char>>>,
-        lines_verticals: Option<HashMap<usize, VerticalLine<char>>>,
-        lines_horizontal1: Option<HorizontalLine<char>>,
+        horizontals: Option<HashMap<usize, HorizontalLine<char>>>,
+        verticals: Option<HashMap<usize, VerticalLine<char>>>,
+        horizontal1: Option<HorizontalLine<char>>,
     ) -> Self {
         Self {
             chars,
             colors,
-            lines_horizontals,
-            lines_verticals,
-            lines_horizontal1,
+            lines_horizontals: horizontals,
+            lines_verticals: verticals,
+            lines_horizontal1: horizontal1,
         }
     }
 }
 
 impl From<Borders<char>> for Theme {
     fn from(borders: Borders<char>) -> Self {
-        Self::gen(borders, Borders::empty(), None, None, None)
+        Self::gen(
+            borders,
+            Borders::empty(),
+            Default::default(),
+            Default::default(),
+            None,
+        )
     }
 }
 
@@ -579,14 +595,14 @@ fn cfg_set_custom_lines(
         cfg.insert_horizontal_line(1, line);
     }
 
-    if let Some(lines) = horizontals {
-        for (row, line) in lines {
+    if let Some(horizontals) = horizontals {
+        for (row, line) in horizontals {
             cfg.insert_horizontal_line(row, line);
         }
     }
 
-    if let Some(lines) = verticals {
-        for (col, line) in lines {
+    if let Some(verticals) = verticals {
+        for (col, line) in verticals {
             cfg.insert_vertical_line(col, line);
         }
     }


Test patch:
diff --git a/tabled/tests/core/table_test.rs b/tabled/tests/core/table_test.rs
index c326426..69df96f 100644
--- a/tabled/tests/core/table_test.rs
+++ b/tabled/tests/core/table_test.rs
@@ -5,8 +5,7 @@ use std::iter::FromIterator;
 use tabled::{
     builder::Builder,
     settings::{
-        formatting::Charset, Border, Height, Highlight, Modify, Padding, Settings, Shadow, Style,
-        Width,
+        formatting::Charset, Height, Highlight, Modify, Padding, Settings, Shadow, Style, Width,
     },
     Table,
 };
@@ -894,7 +893,7 @@ test_table!(
     table_tuple_settings_list_2_test,
     Matrix::new(3, 3)
         .with(Style::markdown())
-        .with((Padding::new(2, 2, 0, 0), Highlight::border((0, 0), Border::filled('*')), Shadow::new(5))),
+        .with((Padding::new(2, 2, 0, 0), Highlight::outline((0, 0), '*'), Shadow::new(5))),
     "*******                                            "
     "*  N  *  column 0  |  column 1  |  column 2  |▒▒▒▒▒"
     "*******------------|------------|------------|▒▒▒▒▒"
diff --git a/tabled/tests/qc/tests/span.rs b/tabled/tests/qc/tests/span.rs
index 48d62e8..13566f6 100644
--- a/tabled/tests/qc/tests/span.rs
+++ b/tabled/tests/qc/tests/span.rs
@@ -9,7 +9,7 @@ use tabled::{
 };
 
 #[quickcheck]
-fn qc_tget_string_widthable_is_consistent_with_hspan_and_vspan(table_structure: TableStructure) {
+fn qc_table_width_is_consistent_with_hspan_and_vspan(table_structure: TableStructure) {
     let mut table = create_table(table_structure.rows);
     set_theme(&mut table, table_structure.theme);
     set_span_hspan(&mut table, &table_structure.row_span);
diff --git a/tabled/tests/settings/highlingt_test.rs b/tabled/tests/settings/highlingt_test.rs
index 90e5d76..543932b 100644
--- a/tabled/tests/settings/highlingt_test.rs
+++ b/tabled/tests/settings/highlingt_test.rs
@@ -14,7 +14,7 @@ use testing_table::{static_table, test_table};
 
 test_table!(
     highlingt_object_exceeds_boundaries,
-    Matrix::new(3, 3).with(Style::modern()).with(Highlight::border(Cell::new(1000, 0), Border::filled('+'))),
+    Matrix::new(3, 3).with(Style::modern()).with(Highlight::new(Cell::new(1000, 0), Border::filled('+'))),
     "┌───┬──────────┬──────────┬──────────┐"
     "│ N │ column 0 │ column 1 │ column 2 │"
     "├───┼──────────┼──────────┼──────────┤"
@@ -30,7 +30,7 @@ test_table!(
     highlingt_empty_table,
     Builder::default()
         .build()
-        .with(Highlight::border(Segment::all(), Border::filled('+'))),
+        .with(Highlight::new(Segment::all(), Border::filled('+'))),
     ""
 );
 
@@ -38,8 +38,8 @@ test_table!(
     highlingt_cell,
     Matrix::new(3, 3)
         .with(Style::modern())
-        .with(Highlight::border(Cell::new(0, 0), Border::filled('+')))
-        .with(Highlight::border(Cell::new(1, 1), Border::filled('*'))),
+        .with(Highlight::new(Cell::new(0, 0), Border::filled('+')))
+        .with(Highlight::new(Cell::new(1, 1), Border::filled('*'))),
     "+++++──────────┬──────────┬──────────┐"
     "+ N + column 0 │ column 1 │ column 2 │"
     "++++************──────────┼──────────┤"
@@ -55,8 +55,8 @@ test_table!(
     highlingt_row,
     Matrix::new(3, 3)
         .with(Style::modern())
-        .with(Highlight::border(Rows::single(0), Border::filled('+')))
-        .with(Highlight::border(Rows::single(3), Border::filled('*'))),
+        .with(Highlight::new(Rows::single(0), Border::filled('+')))
+        .with(Highlight::new(Rows::single(3), Border::filled('*'))),
     "++++++++++++++++++++++++++++++++++++++"
     "+ N │ column 0 │ column 1 │ column 2 +"
     "++++++++++++++++++++++++++++++++++++++"
@@ -72,8 +72,8 @@ test_table!(
     highlingt_column,
     Matrix::new(3, 3)
         .with(Style::modern())
-        .with(Highlight::border(Columns::single(0), Border::filled('+')))
-        .with(Highlight::border(Columns::single(2), Border::filled('*'))),
+        .with(Highlight::new(Columns::single(0), Border::filled('+')))
+        .with(Highlight::new(Columns::single(2), Border::filled('*'))),
     "+++++──────────************──────────┐"
     "+ N + column 0 * column 1 * column 2 │"
     "+───+──────────*──────────*──────────┤"
@@ -89,7 +89,7 @@ test_table!(
     highlingt_row_range,
     Matrix::new(3, 3)
         .with(Style::modern())
-        .with(Highlight::border(Rows::new(1..3), Border::filled('+'))),
+        .with(Highlight::new(Rows::new(1..3), Border::filled('+'))),
     "┌───┬──────────┬──────────┬──────────┐"
     "│ N │ column 0 │ column 1 │ column 2 │"
     "++++++++++++++++++++++++++++++++++++++"
@@ -105,7 +105,7 @@ test_table!(
     highlingt_column_range,
     Matrix::new(3, 3)
         .with(Style::modern())
-        .with(Highlight::border(Columns::new(..2), Border::filled('+'))),
+        .with(Highlight::new(Columns::new(..2), Border::filled('+'))),
     "++++++++++++++++──────────┬──────────┐"
     "+ N │ column 0 + column 1 │ column 2 │"
     "+───┼──────────+──────────┼──────────┤"
@@ -121,7 +121,7 @@ test_table!(
     highlingt_frame,
     Matrix::new(3, 3)
         .with(Style::modern())
-        .with(Highlight::border(
+        .with(Highlight::new(
             Frame,
             Border::filled('+')
                 .set_corner_top_left('*')
@@ -144,7 +144,7 @@ test_table!(
     highlingt_full,
     Matrix::new(3, 3)
         .with(Style::modern())
-        .with(Highlight::border(
+        .with(Highlight::new(
             Segment::all(),
             Border::filled('+')
                 .set_corner_top_left('*')
@@ -167,8 +167,8 @@ test_table!(
     highlingt_single_column,
     Matrix::table(3, 0)
         .with(Style::modern())
-        .with(Highlight::border(Cell::new(0, 0), Border::new().set_left('*').set_top('x')))
-        .with(Highlight::border(Rows::new(1..3), Border::new().set_left('n'))),
+        .with(Highlight::new(Cell::new(0, 0), Border::new().set_left('*').set_top('x')))
+        .with(Highlight::new(Rows::new(1..3), Border::new().set_left('n'))),
     "┌xxx┐"
     "* N │"
     "├───┤"
@@ -184,9 +184,9 @@ test_table!(
     highlingt_several_times,
     Matrix::new(3, 3)
         .with(Style::modern())
-        .with(Highlight::border(Frame, Border::filled('*')))
-        .with(Highlight::border(Cell::new(1, 1), Border::filled('#')))
-        .with(Highlight::border(Columns::single(3), Border::filled('x'))),
+        .with(Highlight::new(Frame, Border::filled('*')))
+        .with(Highlight::new(Cell::new(1, 1), Border::filled('#')))
+        .with(Highlight::new(Columns::single(3), Border::filled('x'))),
     "**************************xxxxxxxxxxxx"
     "* N │ column 0 │ column 1 x column 2 x"
     "*───############──────────x──────────x"
@@ -233,7 +233,7 @@ fn highlingt_complex_figures() {
 
             let table = Matrix::new(3, 3)
                 .with(Style::modern())
-                .with(Highlight::border($object, border))
+                .with(Highlight::new($object, border))
                 .to_string();
 
             assert_eq!(table, $expected);
diff --git a/tabled/tests/settings/margin_test.rs b/tabled/tests/settings/margin_test.rs
index f452bf9..79ac272 100644
--- a/tabled/tests/settings/margin_test.rs
+++ b/tabled/tests/settings/margin_test.rs
@@ -1,8 +1,6 @@
 #![cfg(feature = "std")]
 
-use tabled::settings::{
-    object::Cell, Border, Highlight, Margin, MarginColor, Modify, Span, Style, Width,
-};
+use tabled::settings::{object::Cell, Highlight, Margin, MarginColor, Modify, Span, Style, Width};
 
 use crate::matrix::Matrix;
 use testing_table::{assert_table, assert_width, test_table};
@@ -14,8 +12,8 @@ test_table!(
     margin_with_table_based_on_grid_borders,
     Matrix::new(3, 3)
         .with(Style::extended())
-        .with(Highlight::border(Cell::new(0, 0), Border::filled('+')))
-        .with(Highlight::border(Cell::new(1, 1), Border::filled('*')))
+        .with(Highlight::outline(Cell::new(0, 0), '+'))
+        .with(Highlight::outline(Cell::new(1, 1), '*'))
         .with(Margin::new(1, 2, 1, 2).fill('>', '<', 'V', '^')),
     "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV"
     ">+++++══════════╦══════════╦══════════╗<<"
diff --git a/tabled/tests/settings/panel_test.rs b/tabled/tests/settings/panel_test.rs
index 79d7c4a..ef61d68 100644
--- a/tabled/tests/settings/panel_test.rs
+++ b/tabled/tests/settings/panel_test.rs
@@ -6,7 +6,7 @@ use tabled::settings::{
     object::{Cell, Object, Rows, Segment},
     style::{BorderSpanCorrection, HorizontalLine, Style},
     themes::Theme,
-    Alignment, Border, Highlight, Modify, Panel, Span, Width,
+    Alignment, Highlight, Modify, Panel, Span, Width,
 };
 
 use crate::matrix::Matrix;
@@ -28,7 +28,7 @@ test_table!(
     Matrix::new(3, 3)
         .with(Panel::horizontal(0,"Linux Distributions"))
         .with(Style::psql())
-        .with(Highlight::border(Cell::new(0, 0), Border::filled('#'))),
+        .with(Highlight::outline(Cell::new(0, 0), '#')),
     "#####                                "
     "#        Linux Distributions         "
     "#####----------+----------+----------"
@@ -43,10 +43,10 @@ test_table!(
     Matrix::new(3, 3)
         .with(Panel::horizontal(0,"Linux Distributions"))
         .with(Style::psql())
-        .with(Highlight::border(Cell::new(0, 0), Border::filled('#')))
-        .with(Highlight::border(Cell::new(0, 1), Border::filled('#')))
-        .with(Highlight::border(Cell::new(0, 2), Border::filled('#')))
-        .with(Highlight::border(Cell::new(0, 3), Border::filled('#'))),
+        .with(Highlight::outline(Cell::new(0, 0), '#'))
+        .with(Highlight::outline(Cell::new(0, 1), '#'))
+        .with(Highlight::outline(Cell::new(0, 2), '#'))
+        .with(Highlight::outline(Cell::new(0, 3), '#')),
     "######################################"
     "#        Linux Distributions         #"
     "######################################"
diff --git a/tabled/tests/settings/rotate_test.rs b/tabled/tests/settings/rotate_test.rs
index 7537888..2d906f1 100644
--- a/tabled/tests/settings/rotate_test.rs
+++ b/tabled/tests/settings/rotate_test.rs
@@ -136,7 +136,7 @@ test_table!(
 test_table!(
     rotate_preserve_border_styles_test_0,
     Matrix::iter([(123, 456, 789), (234, 567, 891), (111, 222, 333)])
-        .with(Highlight::border(Rows::single(0), Border::new().set_top('*')))
+        .with(Highlight::new(Rows::single(0), Border::new().set_top('*')))
         .with(Rotate::Left),
     "+*****************+-----+"
     "| i32 | 789 | 891 | 333 |"
@@ -154,7 +154,7 @@ test_table!(
 test_table!(
     rotate_preserve_border_styles_test_1,
     Matrix::iter([(123, 456, 789), (234, 567, 891), (111, 222, 333)])
-        .with(Highlight::border(Cell::new(0, 2), Border::new().set_bottom('*')))
+        .with(Highlight::new(Cell::new(0, 2), Border::new().set_bottom('*')))
         .with(Rotate::Left),
         "+-----+-----+-----+-----+"
         "| i32 | 789 | 891 | 333 |"
diff --git a/tabled/tests/settings/span_test.rs b/tabled/tests/settings/span_test.rs
index 4436139..15cfcf6 100644
--- a/tabled/tests/settings/span_test.rs
+++ b/tabled/tests/settings/span_test.rs
@@ -8,7 +8,7 @@ use tabled::{
     grid::config::Position,
     settings::{
         object::{Columns, Segment},
-        style::{Border, BorderSpanCorrection, Style},
+        style::{BorderSpanCorrection, Style},
         Alignment, Highlight, Modify, Padding, Panel, Span,
     },
     Table,
@@ -1042,7 +1042,7 @@ mod row {
         let table = Table::new(data)
             .with(Modify::new((1, 1)).with(Span::row(3)))
             .with(Style::modern())
-            .with(Highlight::border(Columns::single(1), Border::filled('*')))
+            .with(Highlight::outline(Columns::single(1), '*'))
             .to_string();
 
         assert_eq!(
@@ -1075,7 +1075,7 @@ fn highlight_row_col_span_test() {
     let table = Table::new(data)
         .with(Modify::new((1, 1)).with(Span::row(3)).with(Span::column(2)))
         .with(Style::modern())
-        .with(Highlight::border(Columns::new(1..3), Border::filled('*')))
+        .with(Highlight::outline(Columns::new(1..3), '*'))
         .to_string();
 
     assert_eq!(
diff --git a/tabled/tests/settings/style_test.rs b/tabled/tests/settings/style_test.rs
index bf4d6a7..0370952 100644
--- a/tabled/tests/settings/style_test.rs
+++ b/tabled/tests/settings/style_test.rs
@@ -537,7 +537,7 @@ test_table!(
 
 test_table!(
     style_frame_test_0,
-    Matrix::table(2, 2).with(Highlight::border(Rows::single(1), Border::inherit(Style::modern()))),
+    Matrix::table(2, 2).with(Highlight::new(Rows::single(1), Border::inherit(Style::modern()))),
     "+---+----------+----------+"
     "| N | column 0 | column 1 |"
     "┌─────────────────────────┐"
@@ -551,8 +551,8 @@ test_table!(
     style_frame_test_1,
     Matrix::table(2, 2)
         .with(Style::blank())
-        .with(Highlight::border(Rows::single(0), Border::inherit(Style::extended())))
-        .with(Highlight::border(Rows::single(2), Border::inherit(Style::extended()))),
+        .with(Highlight::new(Rows::single(0), Border::inherit(Style::extended())))
+        .with(Highlight::new(Rows::single(2), Border::inherit(Style::extended()))),
     "╔═════════════════════════╗"
     "║ N   column 0   column 1 ║"
     "╚═════════════════════════╝"