From 307dc1dc51609abe5b6cc5eff944fe51c46a501a Mon Sep 17 00:00:00 2001 From: Alexander Beedie Date: Fri, 30 Dec 2022 22:14:53 +0400 Subject: [PATCH 1/2] new preset "ASCII_FULL_CONDENSED" --- src/style/presets.rs | 15 +++++++++++++-- tests/all/presets_test.rs | 18 +++++++++++++++++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/style/presets.rs b/src/style/presets.rs index ceec2da..17620fd 100644 --- a/src/style/presets.rs +++ b/src/style/presets.rs @@ -11,7 +11,18 @@ /// ``` pub const ASCII_FULL: &str = "||--+==+|-+||++++++"; -/// Default style without any borders. +/// Just like ASCII_FULL, but without dividers between rows. +/// +/// ```text +/// +-------+-------+ +/// | Hello | there | +/// +===============+ +/// | a | b | +/// | c | d | +/// +-------+-------+ +pub const ASCII_FULL_CONDENSED: &str = "||--+==+| ++++++"; + +/// Just like ASCII_FULL, but without any borders. /// /// ```text /// Hello | there @@ -84,7 +95,7 @@ pub const ASCII_MARKDOWN: &str = "|| |-||| "; /// ``` pub const UTF8_FULL: &str = "││──╞═╪╡┆╌┼├┤┬┴┌┐└┘"; -/// Default UTF8 style, but without spacing between rows. +/// Default UTF8 style, but without dividers between rows. /// /// ```text /// ┌───────┬───────┐ diff --git a/tests/all/presets_test.rs b/tests/all/presets_test.rs index 2baa22f..803ac45 100644 --- a/tests/all/presets_test.rs +++ b/tests/all/presets_test.rs @@ -30,6 +30,22 @@ fn test_ascii_full() { assert_eq!("\n".to_string() + &table.to_string(), expected); } +#[test] +fn test_ascii_full_condensed() { + let mut table = get_preset_table(); + table.load_preset(ASCII_FULL_CONDENSED); + println!("{table}"); + let expected = " ++-------+-------+ +| Hello | there | ++===============+ +| a | b | +| c | d | ++-------+-------+"; + println!("{expected}"); + assert_eq!("\n".to_string() + &table.trim_fmt(), expected); +} + #[test] fn test_ascii_no_borders() { let mut table = get_preset_table(); @@ -127,7 +143,7 @@ fn test_utf8_full() { } #[test] -fn test_utf8_condensed() { +fn test_utf8_full_condensed() { let mut table = get_preset_table(); table.load_preset(UTF8_FULL_CONDENSED); println!("{table}"); From b735bf89fd91602a819770914232e00730b3cc4c Mon Sep 17 00:00:00 2001 From: Alexander Beedie Date: Fri, 30 Dec 2022 22:41:14 +0400 Subject: [PATCH 2/2] fix 'iter_kv_map' clippy lint --- src/utils/arrangement/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/arrangement/mod.rs b/src/utils/arrangement/mod.rs index 772e349..1a81af3 100644 --- a/src/utils/arrangement/mod.rs +++ b/src/utils/arrangement/mod.rs @@ -42,7 +42,7 @@ pub fn arrange_content(table: &Table) -> Vec { table_width } else { disabled::arrange(table, &mut infos, visible_columns, &max_content_widths); - return infos.into_iter().map(|(_, info)| info).collect(); + return infos.into_values().collect(); }; match &table.arrangement { @@ -54,7 +54,7 @@ pub fn arrange_content(table: &Table) -> Vec { } } - infos.into_iter().map(|(_, info)| info).collect() + infos.into_values().collect() } #[cfg(test)]