summaryrefslogtreecommitdiffstats
path: root/vendor/tabled/examples/border_text.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/tabled/examples/border_text.rs')
-rw-r--r--vendor/tabled/examples/border_text.rs44
1 files changed, 44 insertions, 0 deletions
diff --git a/vendor/tabled/examples/border_text.rs b/vendor/tabled/examples/border_text.rs
new file mode 100644
index 000000000..bbdb7673e
--- /dev/null
+++ b/vendor/tabled/examples/border_text.rs
@@ -0,0 +1,44 @@
+//! This example demonstrates inserting text into the borders
+//! of a [`Table`] with [`BorderText`]; a powerful labeling tool.
+//!
+//! * [`BorderText`] currently supports:
+//! * Horizontal border placement
+//! * Placement starting column offset
+//! * Text colorization
+//!
+//! * Note how the flexibility of [`Style`] is utilized
+//! to remove horizontal borders from the table entirely,
+//! and then granularly reinserts one for a highly customized
+//! visualization.
+//!
+//! * Note how the [`Rows`] utility object is used to idiomatically
+//! reference the first and last rows of a [`Table`] without writing
+//! the necessary logic by hand.
+//!
+//! * 🚀 Combining several easy-to-use tools,
+//! to create unique data representations is what makes [`tabled`] great!
+
+use tabled::{
+ settings::{
+ object::Rows,
+ style::{BorderText, HorizontalLine, Style},
+ },
+ Table,
+};
+
+fn main() {
+ let data = [[5, 6, 7, 8, 9], [10, 11, 12, 13, 14]];
+
+ let table = Table::new(data)
+ .with(
+ Style::modern()
+ .remove_horizontal()
+ .horizontals([HorizontalLine::new(1, Style::modern().get_horizontal())]),
+ )
+ .with(BorderText::new(" Numbers ").horizontal(Rows::first()))
+ .with(BorderText::new(" More numbers ").horizontal(1))
+ .with(BorderText::new(" end. ").horizontal(Rows::last()))
+ .to_string();
+
+ println!("{table}");
+}