diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-04-07 06:04:52 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-07 06:04:52 +0200 |
| commit | eeabdec14cbceb995e5364045ef1b96720acbd84 (patch) | |
| tree | 01387e87a45c15647e9b74058becf38a49d5827b | |
| parent | a2df05d4d57c863a23b2de57f39e3ec62621e1e4 (diff) | |
| parent | 9a2d0e53f1559f8c356e5692f95c317e960cbf31 (diff) | |
| download | rust-eeabdec14cbceb995e5364045ef1b96720acbd84.tar.gz rust-eeabdec14cbceb995e5364045ef1b96720acbd84.zip | |
Rollup merge of #95708 - fee1-dead:doc_whitespace_trim, r=Dylan-DPC
Update documentation for `trim*` and `is_whitespace` to include newlines
| -rw-r--r-- | library/core/src/char/methods.rs | 3 | ||||
| -rw-r--r-- | library/core/src/str/mod.rs | 16 |
2 files changed, 11 insertions, 8 deletions
diff --git a/library/core/src/char/methods.rs b/library/core/src/char/methods.rs index 3195205b1b6..6a8df7318cd 100644 --- a/library/core/src/char/methods.rs +++ b/library/core/src/char/methods.rs @@ -804,6 +804,9 @@ impl char { /// ``` /// assert!(' '.is_whitespace()); /// + /// // line break + /// assert!('\n'.is_whitespace()); + /// /// // a non-breaking space /// assert!('\u{A0}'.is_whitespace()); /// diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs index 6bfa6a5e015..a1779b78623 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs @@ -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()); /// ``` @@ -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 /// @@ -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: @@ -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 /// @@ -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: |
