Type Alias bytes_utils::string::Str
source · pub type Str = StrInner<Bytes>;
Expand description
Aliased Type§
struct Str(/* private fields */);
Implementations§
source§impl Str
impl Str
sourcepub fn slice_ref(&self, subslice: &str) -> Self
pub fn slice_ref(&self, subslice: &str) -> Self
Extracts owned representation of the slice passed.
This method accepts a string sub-slice of self
. It then extracts the slice but as the
Str type. This makes it easier to use “ordinary” string parsing/manipulation and then go
back to holding the Bytes-based representation.
This is zero-copy, the common part will be shared by reference counting.
Panics
If the provided slice is not a sub-slice of self
. This is checked based on address of the
slice, not on the content.
Example
let owned = Str::from("Hello World");
let borrowed_mid: &str = &owned[2..5];
let mid: Str = owned.slice_ref(borrowed_mid);
assert_eq!("Hello World", owned);
assert_eq!("llo", mid);
sourcepub const fn from_static(s: &'static str) -> Self
pub const fn from_static(s: &'static str) -> Self
Create Str
from static string in O(1).