diff options
| author | okaneco <47607823+okaneco@users.noreply.github.com> | 2023-12-01 18:58:20 -0500 |
|---|---|---|
| committer | okaneco <47607823+okaneco@users.noreply.github.com> | 2023-12-12 12:53:59 -0500 |
| commit | e4808afe8eb97567b6ba457337fbdd321336251e (patch) | |
| tree | 456229e3b1a88a55e54a4f3928ab8784b5f876b0 /library/core/src/slice | |
| parent | 9cf18e98f82d85fa41141391d54485b8747da46f (diff) | |
| download | rust-e4808afe8eb97567b6ba457337fbdd321336251e.tar.gz rust-e4808afe8eb97567b6ba457337fbdd321336251e.zip | |
Add ASCII whitespace trimming functions to `&str`
Add `trim_ascii_start`, `trim_ascii_end`, and `trim_ascii` functions to `&str` for trimming ASCII whitespace under the `byte_slice_trim_ascii` feature gate. Add `inline` to `[u8]` `trim_ascii` functions
Diffstat (limited to 'library/core/src/slice')
| -rw-r--r-- | library/core/src/slice/ascii.rs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/library/core/src/slice/ascii.rs b/library/core/src/slice/ascii.rs index 4cfccd2e3ce..ce04a9f4089 100644 --- a/library/core/src/slice/ascii.rs +++ b/library/core/src/slice/ascii.rs @@ -125,6 +125,7 @@ impl [u8] { /// assert_eq!(b"".trim_ascii_start(), b""); /// ``` #[unstable(feature = "byte_slice_trim_ascii", issue = "94035")] + #[inline] pub const fn trim_ascii_start(&self) -> &[u8] { let mut bytes = self; // Note: A pattern matching based approach (instead of indexing) allows @@ -154,6 +155,7 @@ impl [u8] { /// assert_eq!(b"".trim_ascii_end(), b""); /// ``` #[unstable(feature = "byte_slice_trim_ascii", issue = "94035")] + #[inline] pub const fn trim_ascii_end(&self) -> &[u8] { let mut bytes = self; // Note: A pattern matching based approach (instead of indexing) allows @@ -184,6 +186,7 @@ impl [u8] { /// assert_eq!(b"".trim_ascii(), b""); /// ``` #[unstable(feature = "byte_slice_trim_ascii", issue = "94035")] + #[inline] pub const fn trim_ascii(&self) -> &[u8] { self.trim_ascii_start().trim_ascii_end() } |
