Skip to content

Commit 2b0ce2c

Browse files
authored
Rollup merge of #139031 - DaniPopes:str-trim-closure, r=tgross35
Use char::is_whitespace directly in str::trim* Use the method directly instead of wrapping it in a closure.
2 parents bd3af53 + 781949d commit 2b0ce2c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

library/core/src/str/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2115,7 +2115,7 @@ impl str {
21152115
#[stable(feature = "rust1", since = "1.0.0")]
21162116
#[rustc_diagnostic_item = "str_trim"]
21172117
pub fn trim(&self) -> &str {
2118-
self.trim_matches(|c: char| c.is_whitespace())
2118+
self.trim_matches(char::is_whitespace)
21192119
}
21202120

21212121
/// Returns a string slice with leading whitespace removed.
@@ -2154,7 +2154,7 @@ impl str {
21542154
#[stable(feature = "trim_direction", since = "1.30.0")]
21552155
#[rustc_diagnostic_item = "str_trim_start"]
21562156
pub fn trim_start(&self) -> &str {
2157-
self.trim_start_matches(|c: char| c.is_whitespace())
2157+
self.trim_start_matches(char::is_whitespace)
21582158
}
21592159

21602160
/// Returns a string slice with trailing whitespace removed.
@@ -2193,7 +2193,7 @@ impl str {
21932193
#[stable(feature = "trim_direction", since = "1.30.0")]
21942194
#[rustc_diagnostic_item = "str_trim_end"]
21952195
pub fn trim_end(&self) -> &str {
2196-
self.trim_end_matches(|c: char| c.is_whitespace())
2196+
self.trim_end_matches(char::is_whitespace)
21972197
}
21982198

21992199
/// Returns a string slice with leading whitespace removed.

0 commit comments

Comments
 (0)