From c6268681514c1e4819aafb592f1d05c2206fc481 Mon Sep 17 00:00:00 2001 From: Maxim Zhiburt Date: Mon, 3 Feb 2025 01:51:19 +0300 Subject: [PATCH] Fix clippy --- tabled/src/settings/span/mod.rs | 4 ++-- tabled/src/util/string.rs | 30 ++++++++++++------------------ 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/tabled/src/settings/span/mod.rs b/tabled/src/settings/span/mod.rs index 59e8bd56..c3f568e1 100644 --- a/tabled/src/settings/span/mod.rs +++ b/tabled/src/settings/span/mod.rs @@ -55,7 +55,7 @@ impl Span { /// * == 1 - which is a default span so can be used for removal of spans /// * > 1 - which means to spread a cell by given number of columns right /// * < 0 - which means to spread a cell by given number of columns left - /// + /// /// # Example /// /// ``` @@ -93,7 +93,7 @@ impl Span { /// * == 1 - which is a default span so can be used for removal of spans /// * > 1 - which means to spread a cell by given number of rows bottom /// * < 0 - which means to spread a cell by given number of rows top - /// + /// /// # Example /// /// ``` diff --git a/tabled/src/util/string.rs b/tabled/src/util/string.rs index d857020d..ff7443ca 100644 --- a/tabled/src/util/string.rs +++ b/tabled/src/util/string.rs @@ -233,42 +233,36 @@ mod tests { fn strip_color_test() { let numbers = "\u{1b}[31;100m123456\u{1b}[39m\u{1b}[49m"; - assert_eq!(cut_str(&numbers, 0), "\u{1b}[31;100m\u{1b}[39m\u{1b}[49m"); + assert_eq!(cut_str(numbers, 0), "\u{1b}[31;100m\u{1b}[39m\u{1b}[49m"); + assert_eq!(cut_str(numbers, 3), "\u{1b}[31;100m123\u{1b}[39m\u{1b}[49m"); assert_eq!( - cut_str(&numbers, 3), - "\u{1b}[31;100m123\u{1b}[39m\u{1b}[49m" - ); - assert_eq!( - cut_str(&numbers, 10), + cut_str(numbers, 10), "\u{1b}[31;100m123456\u{1b}[39m\u{1b}[49m" ); let emojies = "\u{1b}[31;100m😳😳😳😳😳\u{1b}[39m\u{1b}[49m"; - assert_eq!(cut_str(&emojies, 0), "\u{1b}[31;100m\u{1b}[39m\u{1b}[49m"); - assert_eq!( - cut_str(&emojies, 3), - "\u{1b}[31;100m😳\u{1b}[39m\u{1b}[49m�" - ); + assert_eq!(cut_str(emojies, 0), "\u{1b}[31;100m\u{1b}[39m\u{1b}[49m"); + assert_eq!(cut_str(emojies, 3), "\u{1b}[31;100m😳\u{1b}[39m\u{1b}[49m�"); assert_eq!( - cut_str(&emojies, 4), + cut_str(emojies, 4), "\u{1b}[31;100m😳😳\u{1b}[39m\u{1b}[49m" ); assert_eq!( - cut_str(&emojies, 20), + cut_str(emojies, 20), "\u{1b}[31;100m😳😳😳😳😳\u{1b}[39m\u{1b}[49m" ); let emojies = "\u{1b}[31;100m🏳️🏳️\u{1b}[39m\u{1b}[49m"; - assert_eq!(cut_str(&emojies, 0), "\u{1b}[31;100m\u{1b}[39m\u{1b}[49m"); - assert_eq!(cut_str(&emojies, 1), "\u{1b}[31;100m🏳\u{1b}[39m\u{1b}[49m"); + assert_eq!(cut_str(emojies, 0), "\u{1b}[31;100m\u{1b}[39m\u{1b}[49m"); + assert_eq!(cut_str(emojies, 1), "\u{1b}[31;100m🏳\u{1b}[39m\u{1b}[49m"); assert_eq!( - cut_str(&emojies, 2), + cut_str(emojies, 2), "\u{1b}[31;100m🏳\u{fe0f}🏳\u{1b}[39m\u{1b}[49m" ); assert_eq!( - get_line_width(&emojies), + get_line_width(emojies), get_line_width("\u{1b}[31;100m🏳\u{fe0f}🏳\u{fe0f}\u{1b}[39m\u{1b}[49m") ); } @@ -278,7 +272,7 @@ mod tests { fn test_color_strip() { let s = "\u{1b}[5;33;48;2;12;200;100mCollored string\u{1b}[0m"; assert_eq!( - cut_str(&s, 1), + cut_str(s, 1), "\u{1b}[5;33;48;2;12;200;100mC\u{1b}[25m\u{1b}[39m\u{1b}[49m" ) }