about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-04-27 11:54:57 +0200
committerGitHub <noreply@github.com>2025-04-27 11:54:57 +0200
commit2b0ce2cf920e7afec602b23518bbbc14d29d6e1d (patch)
treef6bd39d0bcad859e5ff0e6aa7a88d65ab5f687c1
parentbd3af53489275cab11870d3cab915ed9ae9f0484 (diff)
parent781949d68b7393d35e02e7acca6a7d523af1cef8 (diff)
downloadrust-2b0ce2cf920e7afec602b23518bbbc14d29d6e1d.tar.gz
rust-2b0ce2cf920e7afec602b23518bbbc14d29d6e1d.zip
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.
-rw-r--r--library/core/src/str/mod.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs
index 79b4953fcc1..fe35bfdbdf7 100644
--- a/library/core/src/str/mod.rs
+++ b/library/core/src/str/mod.rs
@@ -2115,7 +2115,7 @@ impl str {
     #[stable(feature = "rust1", since = "1.0.0")]
     #[rustc_diagnostic_item = "str_trim"]
     pub fn trim(&self) -> &str {
-        self.trim_matches(|c: char| c.is_whitespace())
+        self.trim_matches(char::is_whitespace)
     }
 
     /// Returns a string slice with leading whitespace removed.
@@ -2154,7 +2154,7 @@ impl str {
     #[stable(feature = "trim_direction", since = "1.30.0")]
     #[rustc_diagnostic_item = "str_trim_start"]
     pub fn trim_start(&self) -> &str {
-        self.trim_start_matches(|c: char| c.is_whitespace())
+        self.trim_start_matches(char::is_whitespace)
     }
 
     /// Returns a string slice with trailing whitespace removed.
@@ -2193,7 +2193,7 @@ impl str {
     #[stable(feature = "trim_direction", since = "1.30.0")]
     #[rustc_diagnostic_item = "str_trim_end"]
     pub fn trim_end(&self) -> &str {
-        self.trim_end_matches(|c: char| c.is_whitespace())
+        self.trim_end_matches(char::is_whitespace)
     }
 
     /// Returns a string slice with leading whitespace removed.