From ec71f3bfd3965e6ec694c6d5c090b301c2f3acd3 Mon Sep 17 00:00:00 2001 From: Weijun Huang Date: Thu, 7 Dec 2023 11:31:21 +0100 Subject: [PATCH] fix closure --- .../physical-expr/src/string_expressions.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/datafusion/physical-expr/src/string_expressions.rs b/datafusion/physical-expr/src/string_expressions.rs index 9a238149411e..406fa120e86c 100644 --- a/datafusion/physical-expr/src/string_expressions.rs +++ b/datafusion/physical-expr/src/string_expressions.rs @@ -323,10 +323,20 @@ fn general_trim( trim_type: TrimType, ) -> Result { let func = match trim_type { - TrimType::Left => str::trim_start_matches::<&str>, - TrimType::Right => str::trim_end_matches::<&str>, - TrimType::Both => |input, pattern| { - str::trim_end_matches(str::trim_start_matches(input, pattern), pattern) + TrimType::Left => |input, pattern: &str| { + let pattern = pattern.chars().collect::>(); + str::trim_start_matches::<&[char]>(input, pattern.as_ref()) + }, + TrimType::Right => |input, pattern: &str| { + let pattern = pattern.chars().collect::>(); + str::trim_end_matches::<&[char]>(input, pattern.as_ref()) + }, + TrimType::Both => |input, pattern: &str| { + let pattern = pattern.chars().collect::>(); + str::trim_end_matches::<&[char]>( + str::trim_start_matches::<&[char]>(input, pattern.as_ref()), + pattern.as_ref(), + ) }, };