/rust/registry/src/index.crates.io-1949cf8c6b5b557f/bstr-1.12.1/src/bstr.rs
Line | Count | Source |
1 | | #[cfg(feature = "alloc")] |
2 | | use alloc::boxed::Box; |
3 | | |
4 | | /// A wrapper for `&[u8]` that provides convenient string oriented trait impls. |
5 | | /// |
6 | | /// If you need ownership or a growable byte string buffer, then use |
7 | | /// [`BString`](struct.BString.html). |
8 | | /// |
9 | | /// Using a `&BStr` is just like using a `&[u8]`, since `BStr` |
10 | | /// implements `Deref` to `[u8]`. So all methods available on `[u8]` |
11 | | /// are also available on `BStr`. |
12 | | /// |
13 | | /// # Representation |
14 | | /// |
15 | | /// A `&BStr` has the same representation as a `&str`. That is, a `&BStr` is |
16 | | /// a fat pointer which consists of a pointer to some bytes and a length. |
17 | | /// |
18 | | /// # Trait implementations |
19 | | /// |
20 | | /// The `BStr` type has a number of trait implementations, and in particular, |
21 | | /// defines equality and ordinal comparisons between `&BStr`, `&str` and |
22 | | /// `&[u8]` for convenience. |
23 | | /// |
24 | | /// The `Debug` implementation for `BStr` shows its bytes as a normal string. |
25 | | /// For invalid UTF-8, hex escape sequences are used. |
26 | | /// |
27 | | /// The `Display` implementation behaves as if `BStr` were first lossily |
28 | | /// converted to a `str`. Invalid UTF-8 bytes are substituted with the Unicode |
29 | | /// replacement codepoint, which looks like this: �. |
30 | | #[repr(transparent)] |
31 | | pub struct BStr { |
32 | | pub(crate) bytes: [u8], |
33 | | } |
34 | | |
35 | | impl BStr { |
36 | | /// Directly creates a `BStr` slice from anything that can be converted |
37 | | /// to a byte slice. |
38 | | /// |
39 | | /// This is very similar to the [`B`](crate::B) function, except this |
40 | | /// returns a `&BStr` instead of a `&[u8]`. |
41 | | /// |
42 | | /// This is a cost-free conversion. |
43 | | /// |
44 | | /// # Example |
45 | | /// |
46 | | /// You can create `BStr`'s from byte arrays, byte slices or even string |
47 | | /// slices: |
48 | | /// |
49 | | /// ``` |
50 | | /// use bstr::BStr; |
51 | | /// |
52 | | /// let a = BStr::new(b"abc"); |
53 | | /// let b = BStr::new(&b"abc"[..]); |
54 | | /// let c = BStr::new("abc"); |
55 | | /// |
56 | | /// assert_eq!(a, b); |
57 | | /// assert_eq!(a, c); |
58 | | /// ``` |
59 | | #[inline] |
60 | 288M | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { |
61 | 288M | BStr::from_bytes(bytes.as_ref()) |
62 | 288M | } <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Line | Count | Source | 60 | 367k | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 367k | BStr::from_bytes(bytes.as_ref()) | 62 | 367k | } |
<bstr::bstr::BStr>::new::<[u8]> Line | Count | Source | 60 | 7.34k | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 7.34k | BStr::from_bytes(bytes.as_ref()) | 62 | 7.34k | } |
<bstr::bstr::BStr>::new::<str> Line | Count | Source | 60 | 12.4k | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 12.4k | BStr::from_bytes(bytes.as_ref()) | 62 | 12.4k | } |
<bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Line | Count | Source | 60 | 6.87M | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 6.87M | BStr::from_bytes(bytes.as_ref()) | 62 | 6.87M | } |
<bstr::bstr::BStr>::new::<[u8]> Line | Count | Source | 60 | 218M | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 218M | BStr::from_bytes(bytes.as_ref()) | 62 | 218M | } |
Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<_> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> <bstr::bstr::BStr>::new::<[u8]> Line | Count | Source | 60 | 8.04k | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 8.04k | BStr::from_bytes(bytes.as_ref()) | 62 | 8.04k | } |
<bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Line | Count | Source | 60 | 5.81k | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 5.81k | BStr::from_bytes(bytes.as_ref()) | 62 | 5.81k | } |
<bstr::bstr::BStr>::new::<[u8]> Line | Count | Source | 60 | 4 | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 4 | BStr::from_bytes(bytes.as_ref()) | 62 | 4 | } |
Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> <bstr::bstr::BStr>::new::<[u8]> Line | Count | Source | 60 | 19.8M | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 19.8M | BStr::from_bytes(bytes.as_ref()) | 62 | 19.8M | } |
Unexecuted instantiation: <bstr::bstr::BStr>::new::<_> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> <bstr::bstr::BStr>::new::<[u8]> Line | Count | Source | 60 | 5.26M | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 5.26M | BStr::from_bytes(bytes.as_ref()) | 62 | 5.26M | } |
Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> <bstr::bstr::BStr>::new::<[u8]> Line | Count | Source | 60 | 6.36k | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 6.36k | BStr::from_bytes(bytes.as_ref()) | 62 | 6.36k | } |
Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<_> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> <bstr::bstr::BStr>::new::<[u8]> Line | Count | Source | 60 | 3.99k | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 3.99k | BStr::from_bytes(bytes.as_ref()) | 62 | 3.99k | } |
<bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Line | Count | Source | 60 | 1.59k | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 1.59k | BStr::from_bytes(bytes.as_ref()) | 62 | 1.59k | } |
<bstr::bstr::BStr>::new::<[u8]> Line | Count | Source | 60 | 6.97M | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 6.97M | BStr::from_bytes(bytes.as_ref()) | 62 | 6.97M | } |
Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> <bstr::bstr::BStr>::new::<[u8]> Line | Count | Source | 60 | 5.52k | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 5.52k | BStr::from_bytes(bytes.as_ref()) | 62 | 5.52k | } |
<bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Line | Count | Source | 60 | 2.02k | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 2.02k | BStr::from_bytes(bytes.as_ref()) | 62 | 2.02k | } |
<bstr::bstr::BStr>::new::<[u8]> Line | Count | Source | 60 | 115k | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 115k | BStr::from_bytes(bytes.as_ref()) | 62 | 115k | } |
Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> <bstr::bstr::BStr>::new::<[u8]> Line | Count | Source | 60 | 37.6k | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 37.6k | BStr::from_bytes(bytes.as_ref()) | 62 | 37.6k | } |
Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> <bstr::bstr::BStr>::new::<[u8]> Line | Count | Source | 60 | 93.8k | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 93.8k | BStr::from_bytes(bytes.as_ref()) | 62 | 93.8k | } |
Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<_> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> <bstr::bstr::BStr>::new::<[u8]> Line | Count | Source | 60 | 1.70k | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 1.70k | BStr::from_bytes(bytes.as_ref()) | 62 | 1.70k | } |
<bstr::bstr::BStr>::new::<[u8]> Line | Count | Source | 60 | 1.29k | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 1.29k | BStr::from_bytes(bytes.as_ref()) | 62 | 1.29k | } |
Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Line | Count | Source | 60 | 53.7k | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 53.7k | BStr::from_bytes(bytes.as_ref()) | 62 | 53.7k | } |
<bstr::bstr::BStr>::new::<[u8]> Line | Count | Source | 60 | 12.6M | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 12.6M | BStr::from_bytes(bytes.as_ref()) | 62 | 12.6M | } |
Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> <bstr::bstr::BStr>::new::<[u8]> Line | Count | Source | 60 | 3.46M | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 3.46M | BStr::from_bytes(bytes.as_ref()) | 62 | 3.46M | } |
Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> <bstr::bstr::BStr>::new::<[u8]> Line | Count | Source | 60 | 1.60M | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 1.60M | BStr::from_bytes(bytes.as_ref()) | 62 | 1.60M | } |
Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Line | Count | Source | 60 | 5.80k | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 5.80k | BStr::from_bytes(bytes.as_ref()) | 62 | 5.80k | } |
<bstr::bstr::BStr>::new::<[u8]> Line | Count | Source | 60 | 3.44M | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 3.44M | BStr::from_bytes(bytes.as_ref()) | 62 | 3.44M | } |
Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Line | Count | Source | 60 | 1.70k | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 1.70k | BStr::from_bytes(bytes.as_ref()) | 62 | 1.70k | } |
<bstr::bstr::BStr>::new::<[u8]> Line | Count | Source | 60 | 149k | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 149k | BStr::from_bytes(bytes.as_ref()) | 62 | 149k | } |
Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> <bstr::bstr::BStr>::new::<[u8]> Line | Count | Source | 60 | 49.3k | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 49.3k | BStr::from_bytes(bytes.as_ref()) | 62 | 49.3k | } |
Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Line | Count | Source | 60 | 1.96k | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 1.96k | BStr::from_bytes(bytes.as_ref()) | 62 | 1.96k | } |
Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Line | Count | Source | 60 | 1.16k | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 1.16k | BStr::from_bytes(bytes.as_ref()) | 62 | 1.16k | } |
<bstr::bstr::BStr>::new::<[u8]> Line | Count | Source | 60 | 2.04M | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 2.04M | BStr::from_bytes(bytes.as_ref()) | 62 | 2.04M | } |
Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> <bstr::bstr::BStr>::new::<[u8]> Line | Count | Source | 60 | 6.71M | pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &BStr { | 61 | 6.71M | BStr::from_bytes(bytes.as_ref()) | 62 | 6.71M | } |
Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> Unexecuted instantiation: <bstr::bstr::BStr>::new::<alloc::vec::Vec<u8>> Unexecuted instantiation: <bstr::bstr::BStr>::new::<[u8]> |
63 | | |
64 | | #[inline] |
65 | 0 | pub(crate) fn new_mut<B: ?Sized + AsMut<[u8]>>( |
66 | 0 | bytes: &mut B, |
67 | 0 | ) -> &mut BStr { |
68 | 0 | BStr::from_bytes_mut(bytes.as_mut()) |
69 | 0 | } Unexecuted instantiation: <bstr::bstr::BStr>::new_mut::<_> Unexecuted instantiation: <bstr::bstr::BStr>::new_mut::<_> Unexecuted instantiation: <bstr::bstr::BStr>::new_mut::<_> Unexecuted instantiation: <bstr::bstr::BStr>::new_mut::<_> |
70 | | |
71 | | #[inline] |
72 | 326M | pub(crate) fn from_bytes(slice: &[u8]) -> &BStr { |
73 | 326M | unsafe { &*(slice as *const [u8] as *const BStr) } |
74 | 326M | } <bstr::bstr::BStr>::from_bytes Line | Count | Source | 72 | 255M | pub(crate) fn from_bytes(slice: &[u8]) -> &BStr { | 73 | 255M | unsafe { &*(slice as *const [u8] as *const BStr) } | 74 | 255M | } |
<bstr::bstr::BStr>::from_bytes Line | Count | Source | 72 | 33.2M | pub(crate) fn from_bytes(slice: &[u8]) -> &BStr { | 73 | 33.2M | unsafe { &*(slice as *const [u8] as *const BStr) } | 74 | 33.2M | } |
<bstr::bstr::BStr>::from_bytes Line | Count | Source | 72 | 35.1M | pub(crate) fn from_bytes(slice: &[u8]) -> &BStr { | 73 | 35.1M | unsafe { &*(slice as *const [u8] as *const BStr) } | 74 | 35.1M | } |
<bstr::bstr::BStr>::from_bytes Line | Count | Source | 72 | 3.46M | pub(crate) fn from_bytes(slice: &[u8]) -> &BStr { | 73 | 3.46M | unsafe { &*(slice as *const [u8] as *const BStr) } | 74 | 3.46M | } |
|
75 | | |
76 | | #[inline] |
77 | 0 | pub(crate) fn from_bytes_mut(slice: &mut [u8]) -> &mut BStr { |
78 | 0 | unsafe { &mut *(slice as *mut [u8] as *mut BStr) } |
79 | 0 | } Unexecuted instantiation: <bstr::bstr::BStr>::from_bytes_mut Unexecuted instantiation: <bstr::bstr::BStr>::from_bytes_mut Unexecuted instantiation: <bstr::bstr::BStr>::from_bytes_mut Unexecuted instantiation: <bstr::bstr::BStr>::from_bytes_mut |
80 | | |
81 | | #[inline] |
82 | | #[cfg(feature = "alloc")] |
83 | 0 | pub(crate) fn from_boxed_bytes(slice: Box<[u8]>) -> Box<BStr> { |
84 | 0 | unsafe { Box::from_raw(Box::into_raw(slice) as _) } |
85 | 0 | } Unexecuted instantiation: <bstr::bstr::BStr>::from_boxed_bytes Unexecuted instantiation: <bstr::bstr::BStr>::from_boxed_bytes Unexecuted instantiation: <bstr::bstr::BStr>::from_boxed_bytes Unexecuted instantiation: <bstr::bstr::BStr>::from_boxed_bytes |
86 | | |
87 | | #[inline] |
88 | | #[cfg(feature = "alloc")] |
89 | 0 | pub(crate) fn into_boxed_bytes(slice: Box<BStr>) -> Box<[u8]> { |
90 | 0 | unsafe { Box::from_raw(Box::into_raw(slice) as _) } |
91 | 0 | } Unexecuted instantiation: <bstr::bstr::BStr>::into_boxed_bytes Unexecuted instantiation: <bstr::bstr::BStr>::into_boxed_bytes Unexecuted instantiation: <bstr::bstr::BStr>::into_boxed_bytes Unexecuted instantiation: <bstr::bstr::BStr>::into_boxed_bytes |
92 | | |
93 | | #[inline] |
94 | 72.9M | pub(crate) fn as_bytes(&self) -> &[u8] { |
95 | 72.9M | &self.bytes |
96 | 72.9M | } <bstr::bstr::BStr>::as_bytes Line | Count | Source | 94 | 31.3M | pub(crate) fn as_bytes(&self) -> &[u8] { | 95 | 31.3M | &self.bytes | 96 | 31.3M | } |
<bstr::bstr::BStr>::as_bytes Line | Count | Source | 94 | 33.9M | pub(crate) fn as_bytes(&self) -> &[u8] { | 95 | 33.9M | &self.bytes | 96 | 33.9M | } |
<bstr::bstr::BStr>::as_bytes Line | Count | Source | 94 | 7.56M | pub(crate) fn as_bytes(&self) -> &[u8] { | 95 | 7.56M | &self.bytes | 96 | 7.56M | } |
<bstr::bstr::BStr>::as_bytes Line | Count | Source | 94 | 9.80k | pub(crate) fn as_bytes(&self) -> &[u8] { | 95 | 9.80k | &self.bytes | 96 | 9.80k | } |
|
97 | | } |