Skip to content
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 @@ -1930,6 +1930,9 @@ impl char {
/// U+0020 SPACE, U+0009 HORIZONTAL TAB, U+000A LINE FEED,
/// U+000C FORM FEED, or U+000D CARRIAGE RETURN.
///
/// **Warning:** Because the list above excludes U+000B VERTICAL TAB,
/// `c.is_ascii_whitespace()` is **not** equivalent to `c.is_ascii() && c.is_whitespace()`.
///
/// Rust uses the WhatWG Infra Standard's [definition of ASCII
/// whitespace][infra-aw]. There are several other definitions in
/// wide use. For instance, [the POSIX locale][pct] includes
Expand Down
3 changes: 3 additions & 0 deletions library/core/src/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,9 @@ impl u8 {
/// U+0020 SPACE, U+0009 HORIZONTAL TAB, U+000A LINE FEED,
/// U+000C FORM FEED, or U+000D CARRIAGE RETURN.
///
/// **Warning:** Because the list above excludes U+000B VERTICAL TAB,
/// `b.is_ascii_whitespace()` is **not** equivalent to `char::from(b).is_whitespace()`.
///
/// Rust uses the WhatWG Infra Standard's [definition of ASCII
/// whitespace][infra-aw]. There are several other definitions in
/// wide use. For instance, [the POSIX locale][pct] includes
Expand Down
18 changes: 15 additions & 3 deletions library/core/src/slice/ascii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,11 @@ impl [u8] {
/// Returns a byte slice with leading ASCII whitespace bytes removed.
///
/// 'Whitespace' refers to the definition used by
/// [`u8::is_ascii_whitespace`].
/// [`u8::is_ascii_whitespace`]. Importantly, this definition excludes
/// the `\0x0B` byte even though it has the Unicode [`White_Space`] property
/// and is removed by [`str::trim_start`].
///
/// [`White_Space`]: https://www.unicode.org/reports/tr44/#White_Space
///
/// # Examples
///
Expand Down Expand Up @@ -251,7 +255,11 @@ impl [u8] {
/// Returns a byte slice with trailing ASCII whitespace bytes removed.
///
/// 'Whitespace' refers to the definition used by
/// [`u8::is_ascii_whitespace`].
/// [`u8::is_ascii_whitespace`]. Importantly, this definition excludes
/// the `\0x0B` byte even though it has the Unicode [`White_Space`] property
/// and is removed by [`str::trim_end`].
Comment on lines +258 to +260
Copy link
Copy Markdown
Contributor

@Jules-Bertholet Jules-Bertholet Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

View changes since the review

Suggested change
/// [`u8::is_ascii_whitespace`]. Importantly, this definition excludes
/// the `\0x0B` byte even though it has the unicode WhiteSpace property
/// and is removed by [`str::trim_end`].
/// [`u8::is_ascii_whitespace`]. Importantly, this definition excludes
/// the `\0x0B` byte even though it has the Unicode [`White_Space`] property
/// and is removed by [`str::trim_end`].
///
/// [`White_Space`]: https://www.unicode.org/reports/tr44/#White_Space

… and so on for other references to the property.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "Importantly, unlike is_whitespace, this definition..." to draw attention to the contrast between them?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asquared31415 I like your idea but I feel like this is already implied by highlighting the difference with the various trim_* and I don't want to make the doc too long so I have elected to not do incoporate your suggestion for now.

///
/// [`White_Space`]: https://www.unicode.org/reports/tr44/#White_Space
///
/// # Examples
///
Expand Down Expand Up @@ -281,7 +289,11 @@ impl [u8] {
/// removed.
///
/// 'Whitespace' refers to the definition used by
/// [`u8::is_ascii_whitespace`].
/// [`u8::is_ascii_whitespace`]. Importantly, this definition excludes
/// the `\0x0B` byte even though it has the Unicode [`White_Space`] property
/// and is removed by [`str::trim`].
///
/// [`White_Space`]: https://www.unicode.org/reports/tr44/#White_Space
///
/// # Examples
///
Expand Down
18 changes: 15 additions & 3 deletions library/core/src/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,9 @@ impl str {
///
/// This uses the same definition as [`char::is_ascii_whitespace`].
/// To split by Unicode `Whitespace` instead, use [`split_whitespace`].
/// Note that because of this difference in definition, even if `s.is_ascii()`
/// is `true`, `s.split_ascii_whitespace()` behavior will differ from `s.split_whitespace()`
/// if `s` contains U+000B VERTICAL TAB.
///
/// [`split_whitespace`]: str::split_whitespace
///
Expand Down Expand Up @@ -2896,9 +2899,12 @@ impl str {
/// Returns a string slice with leading ASCII whitespace removed.
///
/// 'Whitespace' refers to the definition used by
/// [`u8::is_ascii_whitespace`].
/// [`u8::is_ascii_whitespace`]. Importantly, this definition excludes
/// the U+000B code point even though it has the Unicode [`White_Space`] property
/// and is removed by [`str::trim_start`].
///
/// [`u8::is_ascii_whitespace`]: u8::is_ascii_whitespace
/// [`White_Space`]: https://www.unicode.org/reports/tr44/#White_Space
///
/// # Examples
///
Expand All @@ -2921,9 +2927,12 @@ impl str {
/// Returns a string slice with trailing ASCII whitespace removed.
///
/// 'Whitespace' refers to the definition used by
/// [`u8::is_ascii_whitespace`].
/// [`u8::is_ascii_whitespace`]. Importantly, this definition excludes
/// the U+000B code point even though it has the Unicode [`White_Space`] property
/// and is removed by [`str::trim_end`].
///
/// [`u8::is_ascii_whitespace`]: u8::is_ascii_whitespace
/// [`White_Space`]: https://www.unicode.org/reports/tr44/#White_Space
///
/// # Examples
///
Expand All @@ -2947,9 +2956,12 @@ impl str {
/// removed.
///
/// 'Whitespace' refers to the definition used by
/// [`u8::is_ascii_whitespace`].
/// [`u8::is_ascii_whitespace`]. Importantly, this definition excludes
/// the U+000B code point even though it has the Unicode [`White_Space`] property
/// and is removed by [`str::trim`].
///
/// [`u8::is_ascii_whitespace`]: u8::is_ascii_whitespace
/// [`White_Space`]: https://www.unicode.org/reports/tr44/#White_Space
///
/// # Examples
///
Expand Down
Loading