Skip to content

Update documentation for trim* and is_whitespace to include newlines #95708

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 7, 2022
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions library/core/src/char/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,9 @@ impl char {
/// ```
/// assert!(' '.is_whitespace());
///
/// // line break
/// assert!('\n'.is_whitespace());
///
/// // a non-breaking space
/// assert!('\u{A0}'.is_whitespace());
///
Expand Down
16 changes: 8 additions & 8 deletions library/core/src/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1832,14 +1832,14 @@ impl str {
/// Returns a string slice with leading and trailing whitespace removed.
///
/// 'Whitespace' is defined according to the terms of the Unicode Derived
/// Core Property `White_Space`.
/// Core Property `White_Space`, which includes newlines.
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// let s = " Hello\tworld\t";
/// let s = "\n Hello\tworld\t\n";
///
/// assert_eq!("Hello\tworld", s.trim());
/// ```
Expand All @@ -1855,7 +1855,7 @@ impl str {
/// Returns a string slice with leading whitespace removed.
///
/// 'Whitespace' is defined according to the terms of the Unicode Derived
/// Core Property `White_Space`.
/// Core Property `White_Space`, which includes newlines.
///
/// # Text directionality
///
Expand All @@ -1869,8 +1869,8 @@ impl str {
/// Basic usage:
///
/// ```
/// let s = " Hello\tworld\t";
/// assert_eq!("Hello\tworld\t", s.trim_start());
/// let s = "\n Hello\tworld\t\n";
/// assert_eq!("Hello\tworld\t\n", s.trim_start());
/// ```
///
/// Directionality:
Expand All @@ -1894,7 +1894,7 @@ impl str {
/// Returns a string slice with trailing whitespace removed.
///
/// 'Whitespace' is defined according to the terms of the Unicode Derived
/// Core Property `White_Space`.
/// Core Property `White_Space`, which includes newlines.
///
/// # Text directionality
///
Expand All @@ -1908,8 +1908,8 @@ impl str {
/// Basic usage:
///
/// ```
/// let s = " Hello\tworld\t";
/// assert_eq!(" Hello\tworld", s.trim_end());
/// let s = "\n Hello\tworld\t\n";
/// assert_eq!("\n Hello\tworld", s.trim_end());
/// ```
///
/// Directionality:
Expand Down