pub enum InnerAscii {
Owned(SoftAsciiString),
Shared(OwningRef<'static, Arc<String>, SoftAsciiStr>),
}
Expand description
InnerAscii is string data container which can contain either a
owned SoftAsciiString
or a SoftAsciiStr
reference into a shared
string buffer.
Variants§
Owned(SoftAsciiString)
Implementations§
Source§impl InnerAscii
impl InnerAscii
converts this container into on which uses underlying shared data
if the data is already shared nothing is done.
If not the owned data is converted into the underlying string buffer
and OwningRef
is used to enable the shared reference
Note that the underlying buffer is no an SoftAsciiString
but a
String
(from which we happend to know that it fulfills the “is
us-ascii” soft constraint). This allows us to have an InnerAscii
share data with a possible non us-ascii string buffer as long as
the part accessable through the SoftAsciiStr
is ascii. Or at last
should be ascii as it’s a soft constraint.
Source§impl InnerAscii
impl InnerAscii
pub fn new<S: Into<SoftAsciiString>>(data: S) -> Self
Methods from Deref<Target = SoftAsciiStr>§
Sourcepub fn revalidate_soft_constraint(
&self,
) -> Result<&SoftAsciiStr, FromSourceError<&str>>
pub fn revalidate_soft_constraint( &self, ) -> Result<&SoftAsciiStr, FromSourceError<&str>>
reruns checks if the “is us-ascii” soft constraint is still valid
pub fn as_str(&self) -> &str
pub fn lines(&self) -> SoftAsciiLines<'_>
pub fn split_whitespace(&self) -> SoftAsciiSplitWhitespace<'_>
pub fn char_indices(&self) -> SoftAsciiCharIndices<'_>
pub fn chars(&self) -> SoftAsciiChars<'_>
pub fn split_at(&self, mid: usize) -> (&SoftAsciiStr, &SoftAsciiStr)
pub unsafe fn slice_unchecked(&self, begin: usize, end: usize) -> &SoftAsciiStr
Sourcepub unsafe fn get_unchecked<I>(&self, index: I) -> &SoftAsciiStrwhere
I: TempSliceIndexHelper,
pub unsafe fn get_unchecked<I>(&self, index: I) -> &SoftAsciiStrwhere
I: TempSliceIndexHelper,
Proxy of std::str::get_unchecked
.
Currently limited to the various range types:
Range<usize>
RangeInclusive<usize>
RangeFrom<usize>
RangeTo<usize>
RangeToInclusive<usize>
RangeFull
Once all methods on SliceIndex
are stable this
can be implemented using SliceIndex<SoftAsciiStr>
bounds.
pub fn parse<F>(&self) -> Result<F, <F as FromStr>::Err>where
F: FromStr,
pub fn to_lowercase(&self) -> SoftAsciiString
pub fn to_uppercase(&self) -> SoftAsciiString
pub fn repeat(&self, n: usize) -> SoftAsciiString
pub fn trim_right(&self) -> &SoftAsciiStr
pub fn trim_left(&self) -> &SoftAsciiStr
pub fn trim_end(&self) -> &SoftAsciiStr
pub fn trim_start(&self) -> &SoftAsciiStr
pub fn trim(&self) -> &SoftAsciiStr
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn is_char_boundary(&self, index: usize) -> bool
pub fn as_ptr(&self) -> *const u8
pub fn encode_utf16(&self) -> EncodeUtf16<'_>
pub fn is_ascii(&self) -> bool
pub fn as_bytes(&self) -> &[u8] ⓘ
Trait Implementations§
Source§impl AsRef<str> for InnerAscii
impl AsRef<str> for InnerAscii
Source§impl Clone for InnerAscii
impl Clone for InnerAscii
Source§fn clone(&self) -> InnerAscii
fn clone(&self) -> InnerAscii
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more