Skip to content

Use char::is_whitespace directly in str::trim* #139031

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions library/core/src/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
Loading