Perform the actual trimming based on mode
(input: &str, trim_chars: &str, mode: TrimMode)
| 168 | |
| 169 | /// Perform the actual trimming based on mode |
| 170 | fn trim_string(input: &str, trim_chars: &str, mode: TrimMode) -> String { |
| 171 | match mode { |
| 172 | TrimMode::Leading => input |
| 173 | .trim_start_matches(|c: char| trim_chars.contains(c)) |
| 174 | .to_string(), |
| 175 | TrimMode::Trailing => input |
| 176 | .trim_end_matches(|c: char| trim_chars.contains(c)) |
| 177 | .to_string(), |
| 178 | TrimMode::Both => input |
| 179 | .trim_matches(|c: char| trim_chars.contains(c)) |
| 180 | .to_string(), |
| 181 | } |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | impl Function for TrimFunction { |