Skip to content

Commit

Permalink
fix closure
Browse files Browse the repository at this point in the history
  • Loading branch information
Weijun-H committed Dec 7, 2023
1 parent f1ca3be commit 47e7cfb
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions datafusion/physical-expr/src/string_expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,20 @@ fn general_trim<T: OffsetSizeTrait>(
trim_type: TrimType,
) -> Result<ArrayRef> {
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::<Vec<char>>();
str::trim_start_matches::<&[char]>(input, pattern.as_ref())
},
TrimType::Right => |input, pattern: &str| {
let pattern = pattern.chars().collect::<Vec<char>>();
str::trim_end_matches::<&[char]>(input, pattern.as_ref())
},
TrimType::Both => |input, pattern: &str| {
let pattern = pattern.chars().collect::<Vec<char>>();
str::trim_end_matches::<&[char]>(
str::trim_start_matches::<&[char]>(input, pattern.as_ref()),
pattern.as_ref(),
)
},
};

Expand Down

0 comments on commit 47e7cfb

Please sign in to comment.