Rollup merge of #95708 - fee1-dead:doc_whitespace_trim, r=Dylan-DPC

Update documentation for `trim*` and `is_whitespace` to include newlines
This commit is contained in:
Dylan DPC 2022-04-07 06:04:52 +02:00 committed by GitHub
commit eeabdec14c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 8 deletions

View file

@ -804,6 +804,9 @@ pub fn is_uppercase(self) -> bool {
/// ```
/// assert!(' '.is_whitespace());
///
/// // line break
/// assert!('\n'.is_whitespace());
///
/// // a non-breaking space
/// assert!('\u{A0}'.is_whitespace());
///

View file

@ -1832,14 +1832,14 @@ pub fn rmatch_indices<'a, P>(&'a self, pat: P) -> RMatchIndices<'a, P>
/// 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 @@ pub fn trim(&self) -> &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 @@ pub fn trim(&self) -> &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 @@ pub fn trim_start(&self) -> &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 @@ pub fn trim_start(&self) -> &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: