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.
This commit is contained in:
@@ -2115,7 +2115,7 @@ impl str {
|
|||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[rustc_diagnostic_item = "str_trim"]
|
#[rustc_diagnostic_item = "str_trim"]
|
||||||
pub fn trim(&self) -> &str {
|
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.
|
/// Returns a string slice with leading whitespace removed.
|
||||||
@@ -2154,7 +2154,7 @@ impl str {
|
|||||||
#[stable(feature = "trim_direction", since = "1.30.0")]
|
#[stable(feature = "trim_direction", since = "1.30.0")]
|
||||||
#[rustc_diagnostic_item = "str_trim_start"]
|
#[rustc_diagnostic_item = "str_trim_start"]
|
||||||
pub fn trim_start(&self) -> &str {
|
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.
|
/// Returns a string slice with trailing whitespace removed.
|
||||||
@@ -2193,7 +2193,7 @@ impl str {
|
|||||||
#[stable(feature = "trim_direction", since = "1.30.0")]
|
#[stable(feature = "trim_direction", since = "1.30.0")]
|
||||||
#[rustc_diagnostic_item = "str_trim_end"]
|
#[rustc_diagnostic_item = "str_trim_end"]
|
||||||
pub fn trim_end(&self) -> &str {
|
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.
|
/// Returns a string slice with leading whitespace removed.
|
||||||
|
|||||||
Reference in New Issue
Block a user