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).
Source§impl<S: Storage> StrInner<S>
impl<S: Storage> StrInner<S>
Sourcepub fn into_inner(self) -> S
pub fn into_inner(self) -> S
Extracts the inner byte storage.
Sourcepub fn from_inner(s: S) -> Result<Self, Utf8Error<S>>
pub fn from_inner(s: S) -> Result<Self, Utf8Error<S>>
Creates an instance from an existing byte storage.
It may fail if the content is not valid UTF8.
A try_from may be used instead.
Sourcepub const unsafe fn from_inner_unchecked(s: S) -> Self
pub const unsafe fn from_inner_unchecked(s: S) -> Self
Sourcepub fn split_at_bytes(self, at: usize) -> (Self, Self)
pub fn split_at_bytes(self, at: usize) -> (Self, Self)
Sourcepub fn split_whitespace_bytes(self) -> impl Iterator<Item = Self>
pub fn split_whitespace_bytes(self) -> impl Iterator<Item = Self>
Splits into whitespace separated “words”.
This acts like split_whitespace, but yields owned instances. It doesn’t clone the content, it just increments some reference counts.
Sourcepub fn split_ascii_whitespace_bytes(self) -> impl Iterator<Item = Self>
pub fn split_ascii_whitespace_bytes(self) -> impl Iterator<Item = Self>
Splits into whitespace separated “words”.
This acts like split_ascii_whitespace, but yields owned instances. This doesn’t clone the content, it just increments some reference counts.
Sourcepub fn lines_bytes(self) -> impl Iterator<Item = Self>
pub fn lines_bytes(self) -> impl Iterator<Item = Self>
Splits into lines.
This acts like lines, but yields owned instances. The content is not cloned, this just increments some reference counts.
Sourcepub fn split_bytes<'s>(self, sep: &'s str) -> impl Iterator<Item = Self> + 'swhere
S: 's,
pub fn split_bytes<'s>(self, sep: &'s str) -> impl Iterator<Item = Self> + 'swhere
S: 's,
Splits with the provided separator.
This acts somewhat like split, but yields owned instances. Also, it accepts
only string patters (since the Pattern
is not stable ☹). The content is not cloned, this
just increments some reference counts.
Sourcepub fn splitn_bytes<'s>(
self,
n: usize,
sep: &'s str,
) -> impl Iterator<Item = Self> + 'swhere
S: 's,
pub fn splitn_bytes<'s>(
self,
n: usize,
sep: &'s str,
) -> impl Iterator<Item = Self> + 'swhere
S: 's,
Splits max. n
times according to the given pattern.
This acts somewhat like splitn, but yields owned instances. Also, it accepts
only string patters (since the Pattern
is not stable ☹). The content is not cloned, this
just increments some reference counts.
Sourcepub fn rsplit_bytes<'s>(self, sep: &'s str) -> impl Iterator<Item = Self> + 'swhere
S: 's,
pub fn rsplit_bytes<'s>(self, sep: &'s str) -> impl Iterator<Item = Self> + 'swhere
S: 's,
A reverse version of split_bytes.
Sourcepub fn rsplitn_bytes<'s>(
self,
n: usize,
sep: &'s str,
) -> impl Iterator<Item = Self> + 'swhere
S: 's,
pub fn rsplitn_bytes<'s>(
self,
n: usize,
sep: &'s str,
) -> impl Iterator<Item = Self> + 'swhere
S: 's,
A reverse version of splitn_bytes.
Trait Implementations§
Source§impl<S: StorageMut> AddAssign<&str> for StrInner<S>
impl<S: StorageMut> AddAssign<&str> for StrInner<S>
Source§fn add_assign(&mut self, rhs: &str)
fn add_assign(&mut self, rhs: &str)
+=
operation. Read moreSource§impl<S: StorageMut> BorrowMut<str> for StrInner<S>
impl<S: StorageMut> BorrowMut<str> for StrInner<S>
Source§fn borrow_mut(&mut self) -> &mut str
fn borrow_mut(&mut self) -> &mut str
Source§impl<S: StorageMut> DerefMut for StrInner<S>
impl<S: StorageMut> DerefMut for StrInner<S>
Source§impl<'a, S: StorageMut> Extend<&'a String> for StrInner<S>
impl<'a, S: StorageMut> Extend<&'a String> for StrInner<S>
Source§fn extend<T: IntoIterator<Item = &'a String>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = &'a String>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl<'a, S: StorageMut> Extend<&'a char> for StrInner<S>
impl<'a, S: StorageMut> Extend<&'a char> for StrInner<S>
Source§fn extend<T: IntoIterator<Item = &'a char>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = &'a char>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl<'a, S: StorageMut> Extend<&'a str> for StrInner<S>
impl<'a, S: StorageMut> Extend<&'a str> for StrInner<S>
Source§fn extend<T: IntoIterator<Item = &'a str>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = &'a str>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl<S: StorageMut> Extend<Box<str>> for StrInner<S>
impl<S: StorageMut> Extend<Box<str>> for StrInner<S>
Source§fn extend<T: IntoIterator<Item = Box<str>>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Box<str>>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl<'a, S: StorageMut> Extend<Cow<'a, str>> for StrInner<S>
impl<'a, S: StorageMut> Extend<Cow<'a, str>> for StrInner<S>
Source§fn extend<T: IntoIterator<Item = Cow<'a, str>>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Cow<'a, str>>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl<S: StorageMut> Extend<String> for StrInner<S>
impl<S: StorageMut> Extend<String> for StrInner<S>
Source§fn extend<T: IntoIterator<Item = String>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = String>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl<S: StorageMut> Extend<char> for StrInner<S>
impl<S: StorageMut> Extend<char> for StrInner<S>
Source§fn extend<T: IntoIterator<Item = char>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = char>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)