Skip to content

Commit 9a2d0e5

Browse files
committed
Update documentation for trim* and is_whitespace to include newlines
1 parent 949b98c commit 9a2d0e5

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

library/core/src/char/methods.rs

+3
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,9 @@ impl char {
804804
/// ```
805805
/// assert!(' '.is_whitespace());
806806
///
807+
/// // line break
808+
/// assert!('\n'.is_whitespace());
809+
///
807810
/// // a non-breaking space
808811
/// assert!('\u{A0}'.is_whitespace());
809812
///

library/core/src/str/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1832,14 +1832,14 @@ impl str {
18321832
/// Returns a string slice with leading and trailing whitespace removed.
18331833
///
18341834
/// 'Whitespace' is defined according to the terms of the Unicode Derived
1835-
/// Core Property `White_Space`.
1835+
/// Core Property `White_Space`, which includes newlines.
18361836
///
18371837
/// # Examples
18381838
///
18391839
/// Basic usage:
18401840
///
18411841
/// ```
1842-
/// let s = " Hello\tworld\t";
1842+
/// let s = "\n Hello\tworld\t\n";
18431843
///
18441844
/// assert_eq!("Hello\tworld", s.trim());
18451845
/// ```
@@ -1855,7 +1855,7 @@ impl str {
18551855
/// Returns a string slice with leading whitespace removed.
18561856
///
18571857
/// 'Whitespace' is defined according to the terms of the Unicode Derived
1858-
/// Core Property `White_Space`.
1858+
/// Core Property `White_Space`, which includes newlines.
18591859
///
18601860
/// # Text directionality
18611861
///
@@ -1869,8 +1869,8 @@ impl str {
18691869
/// Basic usage:
18701870
///
18711871
/// ```
1872-
/// let s = " Hello\tworld\t";
1873-
/// assert_eq!("Hello\tworld\t", s.trim_start());
1872+
/// let s = "\n Hello\tworld\t\n";
1873+
/// assert_eq!("Hello\tworld\t\n", s.trim_start());
18741874
/// ```
18751875
///
18761876
/// Directionality:
@@ -1894,7 +1894,7 @@ impl str {
18941894
/// Returns a string slice with trailing whitespace removed.
18951895
///
18961896
/// 'Whitespace' is defined according to the terms of the Unicode Derived
1897-
/// Core Property `White_Space`.
1897+
/// Core Property `White_Space`, which includes newlines.
18981898
///
18991899
/// # Text directionality
19001900
///
@@ -1908,8 +1908,8 @@ impl str {
19081908
/// Basic usage:
19091909
///
19101910
/// ```
1911-
/// let s = " Hello\tworld\t";
1912-
/// assert_eq!(" Hello\tworld", s.trim_end());
1911+
/// let s = "\n Hello\tworld\t\n";
1912+
/// assert_eq!("\n Hello\tworld", s.trim_end());
19131913
/// ```
19141914
///
19151915
/// Directionality:

0 commit comments

Comments
 (0)