pub struct _SoftAsciiStr(/* private fields */);
Expand description
A str
wrapper adding a “is us-ascii” soft constraint.
This means that it should be ascii but is not guaranteed to be ascii. Which means non ascii chars are not a safety issue just a potential bug.
This is useful for situations where:
- you would have many unsafe from str conversions/“unnecessary” checks with a strict AsciiStr
- you rarely have to strictly rely on the value being ascii
§Note
Some functions which should be implemented directly
on SoftAsciiStr
like e.g. trim_matches
are only
provided through .as_str()
. This
is because the Pattern API and SliceIndex API is unstable
i.e. can only be implemented in unstable for now.
Once it gets stabilized (rust #27721/#35729) implementations
can be added
Implementations§
Source§impl SoftAsciiStr
impl SoftAsciiStr
pub fn from_unchecked(s: &str) -> &SoftAsciiStr
pub fn from_str_unchecked(s: &str) -> &SoftAsciiStr
pub fn from_unchecked_mut(s: &mut str) -> &mut SoftAsciiStr
pub fn from_str(source: &str) -> Result<&SoftAsciiStr, FromSourceError<&str>>
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 into_soft_ascii_string(self: Box<SoftAsciiStr>) -> SoftAsciiString
pub fn from_boxed_str(bs: Box<str>) -> Box<SoftAsciiStr>
pub fn into_boxed_str(self: Box<SoftAsciiStr>) -> Box<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.
Sourcepub fn inner_str_mut(&mut self) -> &mut str
pub fn inner_str_mut(&mut self) -> &mut str
returns a mutable str
reference to the inner buffer
§Soft Constraint
be aware that it is very easy to introduce bugs when
directly editing a SoftAsciiStr
as an str
. Still
compared to a AsciiStr implementation this won’t
introduce unsafety, just possible brakeage of the
soft constraint that the data should be ascii.
pub fn parse<F>(&self) -> Result<F, <F as FromStr>::Err>where
F: FromStr,
Source§impl SoftAsciiStr
impl SoftAsciiStr
pub fn to_lowercase(&self) -> SoftAsciiString
Source§impl SoftAsciiStr
impl SoftAsciiStr
pub fn to_uppercase(&self) -> SoftAsciiString
Source§impl SoftAsciiStr
impl SoftAsciiStr
pub fn repeat(&self, n: usize) -> SoftAsciiString
Source§impl SoftAsciiStr
impl SoftAsciiStr
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
Source§impl SoftAsciiStr
impl SoftAsciiStr
Trait Implementations§
Source§impl AsRef<[u8]> for SoftAsciiStr
impl AsRef<[u8]> for SoftAsciiStr
Source§impl AsRef<OsStr> for SoftAsciiStr
impl AsRef<OsStr> for SoftAsciiStr
Source§impl AsRef<Path> for SoftAsciiStr
impl AsRef<Path> for SoftAsciiStr
Source§impl AsRef<SoftAsciiStr> for SoftAsciiStr
impl AsRef<SoftAsciiStr> for SoftAsciiStr
Source§fn as_ref(&self) -> &SoftAsciiStr
fn as_ref(&self) -> &SoftAsciiStr
Source§impl AsRef<str> for SoftAsciiStr
impl AsRef<str> for SoftAsciiStr
Source§impl Debug for SoftAsciiStr
impl Debug for SoftAsciiStr
Source§impl<'a> Default for &'a SoftAsciiStr
impl<'a> Default for &'a SoftAsciiStr
Source§fn default() -> &'a SoftAsciiStr
fn default() -> &'a SoftAsciiStr
Source§impl Display for SoftAsciiStr
impl Display for SoftAsciiStr
Source§impl Hash for SoftAsciiStr
impl Hash for SoftAsciiStr
Source§impl Index<RangeFull> for SoftAsciiStr
impl Index<RangeFull> for SoftAsciiStr
Source§impl Ord for SoftAsciiStr
impl Ord for SoftAsciiStr
Source§impl<'a, 'b> PartialEq<Cow<'a, SoftAsciiStr>> for &'a SoftAsciiStr
impl<'a, 'b> PartialEq<Cow<'a, SoftAsciiStr>> for &'a SoftAsciiStr
Source§impl<'a> PartialEq<Cow<'a, SoftAsciiStr>> for SoftAsciiStr
impl<'a> PartialEq<Cow<'a, SoftAsciiStr>> for SoftAsciiStr
Source§impl PartialEq<OsStr> for SoftAsciiStr
impl PartialEq<OsStr> for SoftAsciiStr
Source§impl<'a> PartialEq<OsString> for &'a SoftAsciiStr
impl<'a> PartialEq<OsString> for &'a SoftAsciiStr
Source§impl PartialEq<OsString> for SoftAsciiStr
impl PartialEq<OsString> for SoftAsciiStr
Source§impl PartialEq<SoftAsciiStr> for HeaderName
impl PartialEq<SoftAsciiStr> for HeaderName
Source§impl PartialEq<SoftAsciiStr> for OsStr
impl PartialEq<SoftAsciiStr> for OsStr
Source§impl<'a> PartialEq<SoftAsciiStr> for str
impl<'a> PartialEq<SoftAsciiStr> for str
Source§impl<'a> PartialEq<SoftAsciiString> for &'a SoftAsciiStr
impl<'a> PartialEq<SoftAsciiString> for &'a SoftAsciiStr
Source§impl PartialEq<SoftAsciiString> for SoftAsciiStr
impl PartialEq<SoftAsciiString> for SoftAsciiStr
Source§impl<'a> PartialEq<String> for &'a SoftAsciiStr
impl<'a> PartialEq<String> for &'a SoftAsciiStr
Source§impl PartialEq<String> for SoftAsciiStr
impl PartialEq<String> for SoftAsciiStr
Source§impl PartialEq<str> for SoftAsciiStr
impl PartialEq<str> for SoftAsciiStr
Source§impl PartialEq for SoftAsciiStr
impl PartialEq for SoftAsciiStr
Source§impl PartialOrd for SoftAsciiStr
impl PartialOrd for SoftAsciiStr
Source§impl ToOwned for SoftAsciiStr
impl ToOwned for SoftAsciiStr
Source§type Owned = SoftAsciiString
type Owned = SoftAsciiString
Source§fn to_owned(&self) -> SoftAsciiString
fn to_owned(&self) -> SoftAsciiString
1.63.0 · Source§fn clone_into(&self, target: &mut Self::Owned)
fn clone_into(&self, target: &mut Self::Owned)
Source§impl ToSocketAddrs for SoftAsciiStr
impl ToSocketAddrs for SoftAsciiStr
Source§type Iter = IntoIter<SocketAddr>
type Iter = IntoIter<SocketAddr>
Source§fn to_socket_addrs(&self) -> Result<IntoIter<SocketAddr>, Error>
fn to_socket_addrs(&self) -> Result<IntoIter<SocketAddr>, Error>
SocketAddr
s. Read more