Lines Matching defs:BStr
13 pub struct BStr([u8]);
15 impl BStr {
28 /// Creates a [`BStr`] from a `[u8]`.
31 // SAFETY: `BStr` is transparent to `[u8]`.
32 unsafe { &*(bytes as *const [u8] as *const BStr) }
36 impl fmt::Display for BStr {
40 /// # use kernel::{fmt, b_str, str::{BStr, CString}};
41 /// let ascii = b_str!("Hello, BStr!");
43 /// assert_eq!(s.as_bytes(), "Hello, BStr!".as_bytes());
66 impl fmt::Debug for BStr {
71 /// # use kernel::{fmt, b_str, str::{BStr, CString}};
73 /// let ascii = b_str!("Hello, \"BStr\"!");
75 /// assert_eq!(s.as_bytes(), "\"Hello, \\\"BStr\\\"!\"".as_bytes());
102 impl Deref for BStr {
111 /// Creates a new [`BStr`] from a string literal.
120 /// # use kernel::str::BStr;
121 /// const MY_BSTR: &BStr = b_str!("My awesome BStr!");
127 const C: &'static $crate::str::BStr = $crate::str::BStr::from_bytes(S.as_bytes());
443 impl AsRef<BStr> for CStr {
445 fn as_ref(&self) -> &BStr {
446 BStr::from_bytes(self.as_bytes())
451 type Target = BStr;
484 // Marker trait for index types that can be forward to `BStr`.
496 BStr: Index<Idx>,
498 type Output = <BStr as Index<Idx>>::Output;
632 let hello_world = BStr::from_bytes(b"hello, world!");
634 let escapes = BStr::from_bytes(b"_\t_\n_\r_\\_\'_\"_");
636 let others = BStr::from_bytes(b"\x01");
638 let non_ascii = BStr::from_bytes(b"d\xe9j\xe0 vu");
640 let good_bytes = BStr::from_bytes(b"\xf0\x9f\xa6\x80");
646 let hello_world = BStr::from_bytes(b"hello, world!");
648 let escapes = BStr::from_bytes(b"_\t_\n_\r_\\_\'_\"_");
650 let others = BStr::from_bytes(b"\x01");
652 let non_ascii = BStr::from_bytes(b"d\xe9j\xe0 vu");
654 let good_bytes = BStr::from_bytes(b"\xf0\x9f\xa6\x80");