| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#; |
| 2 | |
| 3 | use ::bstrrust-analyzer cargo bstr 1.12.3 crate/::{BStrrust-analyzer cargo bstr 1.12.3 bstr/BStr#, BStringrust-analyzer cargo bstr 1.12.3 bstring/BString#}; |
| 4 | |
| 5 | /// Provide a borrowed byte-string view of common string and byte containers. |
| 6 | /// |
| 7 | /// Unlike [`AsRef`], this conversion deliberately bridges representations such |
| 8 | /// as [`String`] and [`Vec<u8>`] to [`BStr`] without allocating. |
| 9 | pub trait AsBStrrust-analyzer cargo gix-utils 0.3.5 bstr/AsBStr# { |
| 10 | /// Return this value as a borrowed byte string. |
| 11 | fn as_bstrrust-analyzer cargo gix-utils 0.3.5 bstr/AsBStr#as_bstr().(&self) -> &BStrrust-analyzer cargo bstr 1.12.3 bstr/BStr#; |
| 12 | } |
| 13 | |
| 14 | /// Provide an optional borrowed byte-string view of common string and byte containers. |
| 15 | pub trait AsBStrOptrust-analyzer cargo gix-utils 0.3.5 bstr/AsBStrOpt# { |
| 16 | /// Return this value as a borrowed byte string, or `None` if it is absent. |
| 17 | fn as_bstr_optrust-analyzer cargo gix-utils 0.3.5 bstr/AsBStrOpt#as_bstr_opt().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&BStrrust-analyzer cargo bstr 1.12.3 bstr/BStr#>; |
| 18 | } |
| 19 | |
| 20 | impl<T: AsBStrrust-analyzer cargo gix-utils 0.3.5 bstr/AsBStr# + ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#> AsBStrOptrust-analyzer cargo gix-utils 0.3.5 bstr/AsBStrOpt# for T { |
| 21 | fn as_bstr_optrust-analyzer cargo gix-utils 0.3.5 bstr/impl#[T][AsBStrOpt]as_bstr_opt().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&BStrrust-analyzer cargo bstr 1.12.3 bstr/BStr#> { |
| 22 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.as_bstrrust-analyzer cargo gix-utils 0.3.5 bstr/AsBStr#as_bstr().()) |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | impl AsBStrOptrust-analyzer cargo gix-utils 0.3.5 bstr/AsBStrOpt# for Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&BStrrust-analyzer cargo bstr 1.12.3 bstr/BStr#> { |
| 27 | fn as_bstr_optrust-analyzer cargo gix-utils 0.3.5 bstr/impl#[`Option<&BStr>`][AsBStrOpt]as_bstr_opt().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&BStrrust-analyzer cargo bstr 1.12.3 bstr/BStr#> { |
| 28 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | impl<T: AsBStrrust-analyzer cargo gix-utils 0.3.5 bstr/AsBStr# + ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#> AsBStrrust-analyzer cargo gix-utils 0.3.5 bstr/AsBStr# for &T { |
| 33 | fn as_bstrrust-analyzer cargo gix-utils 0.3.5 bstr/impl#[`&T`][AsBStr]as_bstr().(&self) -> &BStrrust-analyzer cargo bstr 1.12.3 bstr/BStr# { |
| 34 | T::as_bstrrust-analyzer cargo gix-utils 0.3.5 bstr/AsBStr#as_bstr().(self) |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | impl<T: AsBStrrust-analyzer cargo gix-utils 0.3.5 bstr/AsBStr# + ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#> AsBStrrust-analyzer cargo gix-utils 0.3.5 bstr/AsBStr# for &mut T { |
| 39 | fn as_bstrrust-analyzer cargo gix-utils 0.3.5 bstr/impl#[`&mut T`][AsBStr]as_bstr().(&self) -> &BStrrust-analyzer cargo bstr 1.12.3 bstr/BStr# { |
| 40 | T::as_bstrrust-analyzer cargo gix-utils 0.3.5 bstr/AsBStr#as_bstr().(self) |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | impl AsBStrrust-analyzer cargo gix-utils 0.3.5 bstr/AsBStr# for BStrrust-analyzer cargo bstr 1.12.3 bstr/BStr# { |
| 45 | fn as_bstrrust-analyzer cargo gix-utils 0.3.5 bstr/impl#[BStr][AsBStr]as_bstr().(&self) -> &BStrrust-analyzer cargo bstr 1.12.3 bstr/BStr# { |
| 46 | self |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | impl AsBStrrust-analyzer cargo gix-utils 0.3.5 bstr/AsBStr# for BStringrust-analyzer cargo bstr 1.12.3 bstring/BString# { |
| 51 | fn as_bstrrust-analyzer cargo gix-utils 0.3.5 bstr/impl#[BString][AsBStr]as_bstr().(&self) -> &BStrrust-analyzer cargo bstr 1.12.3 bstr/BStr# { |
| 52 | BStrrust-analyzer cargo bstr 1.12.3 bstr/BStr#::newrust-analyzer cargo bstr 1.12.3 bstr/impl#[BStr]new().(self.as_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]as_slice().()) |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | impl AsBStrrust-analyzer cargo gix-utils 0.3.5 bstr/AsBStr# for str { |
| 57 | fn as_bstrrust-analyzer cargo gix-utils 0.3.5 bstr/impl#[str][AsBStr]as_bstr().(&self) -> &BStrrust-analyzer cargo bstr 1.12.3 bstr/BStr# { |
| 58 | BStrrust-analyzer cargo bstr 1.12.3 bstr/BStr#::newrust-analyzer cargo bstr 1.12.3 bstr/impl#[BStr]new().(self) |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | impl AsBStrrust-analyzer cargo gix-utils 0.3.5 bstr/AsBStr# for Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 63 | fn as_bstrrust-analyzer cargo gix-utils 0.3.5 bstr/impl#[String][AsBStr]as_bstr().(&self) -> &BStrrust-analyzer cargo bstr 1.12.3 bstr/BStr# { |
| 64 | BStrrust-analyzer cargo bstr 1.12.3 bstr/BStr#::newrust-analyzer cargo bstr 1.12.3 bstr/impl#[BStr]new().(self) |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | impl AsBStrrust-analyzer cargo gix-utils 0.3.5 bstr/AsBStr# for [u8] { |
| 69 | fn as_bstrrust-analyzer cargo gix-utils 0.3.5 bstr/impl#[`[u8]`][AsBStr]as_bstr().(&self) -> &BStrrust-analyzer cargo bstr 1.12.3 bstr/BStr# { |
| 70 | BStrrust-analyzer cargo bstr 1.12.3 bstr/BStr#::newrust-analyzer cargo bstr 1.12.3 bstr/impl#[BStr]new().(self) |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | impl AsBStrrust-analyzer cargo gix-utils 0.3.5 bstr/AsBStr# for Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> { |
| 75 | fn as_bstrrust-analyzer cargo gix-utils 0.3.5 bstr/impl#[`Vec<u8>`][AsBStr]as_bstr().(&self) -> &BStrrust-analyzer cargo bstr 1.12.3 bstr/BStr# { |
| 76 | BStrrust-analyzer cargo bstr 1.12.3 bstr/BStr#::newrust-analyzer cargo bstr 1.12.3 bstr/impl#[BStr]new().(self) |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | impl<const N: usize> AsBStrrust-analyzer cargo gix-utils 0.3.5 bstr/AsBStr# for [u8; N] { |
| 81 | fn as_bstrrust-analyzer cargo gix-utils 0.3.5 bstr/impl#[`[u8; N]`][AsBStr]as_bstr().(&self) -> &BStrrust-analyzer cargo bstr 1.12.3 bstr/BStr# { |
| 82 | BStrrust-analyzer cargo bstr 1.12.3 bstr/BStr#::newrust-analyzer cargo bstr 1.12.3 bstr/impl#[BStr]new().(self) |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | impl<T> AsBStrrust-analyzer cargo gix-utils 0.3.5 bstr/AsBStr# for Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'_, T> |
| 87 | where |
| 88 | T: AsBStrrust-analyzer cargo gix-utils 0.3.5 bstr/AsBStr# + ToOwnedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/ToOwned# + ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#, |
| 89 | { |
| 90 | fn as_bstrrust-analyzer cargo gix-utils 0.3.5 bstr/impl#[`Cow<'_, T>`][AsBStr]as_bstr().(&self) -> &BStrrust-analyzer cargo bstr 1.12.3 bstr/BStr# { |
| 91 | self.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, T>`][`AsRef<T>`]as_ref().().as_bstrrust-analyzer cargo gix-utils 0.3.5 bstr/AsBStr#as_bstr().() |
| 92 | } |
| 93 | } |