Skip to content

Commit 7a11c72

Browse files
committed
is_ascii on an empty string or slice returns true
1 parent f524236 commit 7a11c72

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

library/core/src/slice/ascii.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ use crate::{ascii, iter, ops};
99

1010
impl [u8] {
1111
/// Checks if all bytes in this slice are within the ASCII range.
12+
///
13+
/// An empty slice returns `true`.
1214
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
1315
#[rustc_const_stable(feature = "const_slice_is_ascii", since = "1.74.0")]
1416
#[must_use]

library/core/src/str/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2704,6 +2704,8 @@ impl str {
27042704

27052705
/// Checks if all characters in this string are within the ASCII range.
27062706
///
2707+
/// An empty string returns `true`.
2708+
///
27072709
/// # Examples
27082710
///
27092711
/// ```

library/std/src/ffi/os_str.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,6 +1215,8 @@ impl OsStr {
12151215

12161216
/// Checks if all characters in this string are within the ASCII range.
12171217
///
1218+
/// An empty string returns `true`.
1219+
///
12181220
/// # Examples
12191221
///
12201222
/// ```

0 commit comments

Comments
 (0)