From 03aa338897f085a541a35c4186447af1aa7fa452 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Fri, 1 Jul 2022 11:36:08 -0400 Subject: [PATCH] fix: Remove unnecessary String allocations found by clippy --- influxdb_line_protocol/src/lib.rs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/influxdb_line_protocol/src/lib.rs b/influxdb_line_protocol/src/lib.rs index ecf456115f..0b90780470 100644 --- a/influxdb_line_protocol/src/lib.rs +++ b/influxdb_line_protocol/src/lib.rs @@ -1039,7 +1039,7 @@ const TAG_VALUE_DELIMITERS: &[char] = TAG_KEY_DELIMITERS; const FIELD_KEY_DELIMITERS: &[char] = TAG_KEY_DELIMITERS; /// Characters to escape when writing string values in fields -const FIELD_VALUE_STRING_DELIMITERS: &[char] = &['"']; +const FIELD_VALUE_STRING_DELIMITERS: &[char] = &['"']; // " Close quotes for buggy editor /// Writes a str value to f, escaping all caracters in /// escaping_escaping specificiation. @@ -1144,19 +1144,16 @@ mod test { #[test] fn test_trim_leading() { - assert_eq!(trim_leading(&String::from("")), ""); - assert_eq!(trim_leading(&String::from(" a b c ")), "a b c "); - assert_eq!(trim_leading(&String::from(" a ")), "a "); - assert_eq!(trim_leading(&String::from("\n a ")), "a "); - assert_eq!(trim_leading(&String::from("\t a ")), "a "); + assert_eq!(trim_leading(""), ""); + assert_eq!(trim_leading(" a b c "), "a b c "); + assert_eq!(trim_leading(" a "), "a "); + assert_eq!(trim_leading("\n a "), "a "); + assert_eq!(trim_leading("\t a "), "a "); // comments - assert_eq!(trim_leading(&String::from(" #comment\n a ")), "a "); - assert_eq!(trim_leading(&String::from("#comment\tcomment")), ""); - assert_eq!( - trim_leading(&String::from("#comment\n #comment2\n#comment\na")), - "a" - ); + assert_eq!(trim_leading(" #comment\n a "), "a "); + assert_eq!(trim_leading("#comment\tcomment"), ""); + assert_eq!(trim_leading("#comment\n #comment2\n#comment\na"), "a"); } #[test]