Skip to content

Commit 7c59774

Browse files
nbdd0121ojeda
authored andcommitted
rust: str: add BStr type
Add the `BStr` type, which is a byte string without UTF-8 validity guarantee. It is simply an alias to `[u8]`, but has a more evident semantical meaning. Signed-off-by: Gary Guo <gary@garyguo.net> [Reworded, adapted for upstream and applied latest changes] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent feadd06 commit 7c59774

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

rust/kernel/str.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
55
use core::fmt;
66

7+
/// Byte string without UTF-8 validity guarantee.
8+
///
9+
/// `BStr` is simply an alias to `[u8]`, but has a more evident semantical meaning.
10+
pub type BStr = [u8];
11+
712
/// Allows formatting of [`fmt::Arguments`] into a raw buffer.
813
///
914
/// It does not fail if callers write past the end of the buffer so that they can calculate the

0 commit comments

Comments
 (0)