[−][src]Struct soft_ascii_string::SoftAsciiStr
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
Methods
impl SoftAsciiStr
[src]
pub fn from_unchecked(s: &str) -> &SoftAsciiStr
[src]
pub fn from_str_unchecked(s: &str) -> &SoftAsciiStr
[src]
use from_unchecked
pub fn from_unchecked_mut(s: &mut str) -> &mut SoftAsciiStr
[src]
pub fn from_str(source: &str) -> Result<&Self, FromSourceError<&str>>
[src]
pub fn revalidate_soft_constraint(&self) -> Result<&Self, FromSourceError<&str>>
[src]
reruns checks if the "is us-ascii" soft constraint is still valid
pub fn as_str(&self) -> &str
[src]
pub fn into_soft_ascii_string(self: Box<SoftAsciiStr>) -> SoftAsciiString
[src]
pub fn from_boxed_str(bs: Box<str>) -> Box<SoftAsciiStr>
[src]
pub fn into_boxed_str(self: Box<SoftAsciiStr>) -> Box<str>
[src]
ⓘImportant traits for SoftAsciiLines<'a>pub fn lines(&self) -> SoftAsciiLines
[src]
ⓘImportant traits for SoftAsciiSplitWhitespace<'a>pub fn split_whitespace(&self) -> SoftAsciiSplitWhitespace
[src]
ⓘImportant traits for SoftAsciiCharIndices<'a>pub fn char_indices(&self) -> SoftAsciiCharIndices
[src]
ⓘImportant traits for SoftAsciiChars<'a>pub fn chars(&self) -> SoftAsciiChars
[src]
pub fn split_at(&self, mid: usize) -> (&SoftAsciiStr, &SoftAsciiStr)
[src]
pub unsafe fn slice_unchecked(&self, begin: usize, end: usize) -> &SoftAsciiStr
[src]
deprecated in std
pub unsafe fn get_unchecked<I>(&self, index: I) -> &SoftAsciiStr where
I: TempSliceIndexHelper,
[src]
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 inner_str_mut(&mut self) -> &mut str
[src]
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,
[src]
F: FromStr,
impl SoftAsciiStr
[src]
pub fn to_lowercase(&self) -> SoftAsciiString
[src]
impl SoftAsciiStr
[src]
pub fn to_uppercase(&self) -> SoftAsciiString
[src]
impl SoftAsciiStr
[src]
pub fn repeat(&self, n: usize) -> SoftAsciiString
[src]
impl SoftAsciiStr
[src]
pub fn trim_right(&self) -> &SoftAsciiStr
[src]
deprecated in std
pub fn trim_left(&self) -> &SoftAsciiStr
[src]
deprecated in std
pub fn trim_end(&self) -> &SoftAsciiStr
[src]
pub fn trim_start(&self) -> &SoftAsciiStr
[src]
pub fn trim(&self) -> &SoftAsciiStr
[src]
impl SoftAsciiStr
[src]
pub fn len(&self) -> usize
[src]
pub fn is_empty(&self) -> bool
[src]
pub fn is_char_boundary(&self, index: usize) -> bool
[src]
pub fn as_ptr(&self) -> *const u8
[src]
pub fn encode_utf16(&self) -> EncodeUtf16
[src]
pub fn is_ascii(&self) -> bool
[src]
pub fn as_bytes(&self) -> &[u8]
[src]
Trait Implementations
impl<'a> Add<&'a SoftAsciiStr> for SoftAsciiString
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, other: &'a SoftAsciiStr) -> Self
[src]
impl<'a> AddAssign<&'a SoftAsciiStr> for SoftAsciiString
[src]
fn add_assign(&mut self, other: &'a SoftAsciiStr)
[src]
impl AsRef<[u8]> for SoftAsciiStr
[src]
impl AsRef<OsStr> for SoftAsciiStr
[src]
impl AsRef<Path> for SoftAsciiStr
[src]
impl AsRef<SoftAsciiStr> for SoftAsciiStr
[src]
impl AsRef<SoftAsciiStr> for SoftAsciiString
[src]
fn as_ref(&self) -> &SoftAsciiStr
[src]
impl AsRef<str> for SoftAsciiStr
[src]
impl Borrow<SoftAsciiStr> for SoftAsciiString
[src]
fn borrow(&self) -> &SoftAsciiStr
[src]
impl Debug for SoftAsciiStr
[src]
impl<'a> Default for &'a SoftAsciiStr
[src]
fn default() -> &'a SoftAsciiStr
[src]
impl Display for SoftAsciiStr
[src]
impl Eq for SoftAsciiStr
[src]
impl<'a> Extend<&'a SoftAsciiStr> for SoftAsciiString
[src]
fn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = &'a SoftAsciiStr>,
[src]
I: IntoIterator<Item = &'a SoftAsciiStr>,
impl<'a> From<&'a SoftAsciiStr> for SoftAsciiChars<'a>
[src]
ⓘImportant traits for SoftAsciiChars<'a>fn from(s: &'a SoftAsciiStr) -> SoftAsciiChars<'a>
[src]
impl<'a> From<&'a SoftAsciiStr> for SoftAsciiCharIndices<'a>
[src]
ⓘImportant traits for SoftAsciiCharIndices<'a>fn from(s: &'a SoftAsciiStr) -> SoftAsciiCharIndices<'a>
[src]
impl<'a> From<&'a SoftAsciiStr> for SoftAsciiLines<'a>
[src]
ⓘImportant traits for SoftAsciiLines<'a>fn from(s: &'a SoftAsciiStr) -> SoftAsciiLines<'a>
[src]
impl<'a> From<&'a SoftAsciiStr> for SoftAsciiSplitWhitespace<'a>
[src]
ⓘImportant traits for SoftAsciiSplitWhitespace<'a>fn from(s: &'a SoftAsciiStr) -> SoftAsciiSplitWhitespace<'a>
[src]
impl<'a> From<&'a SoftAsciiStr> for SoftAsciiString
[src]
fn from(s: &'a SoftAsciiStr) -> Self
[src]
impl<'a> FromIterator<&'a SoftAsciiStr> for SoftAsciiString
[src]
fn from_iter<I>(iter: I) -> Self where
I: IntoIterator<Item = &'a SoftAsciiStr>,
[src]
I: IntoIterator<Item = &'a SoftAsciiStr>,
impl Hash for SoftAsciiStr
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Index<Range<usize>> for SoftAsciiStr
[src]
type Output = SoftAsciiStr
The returned type after indexing.
fn index(&self, index: Range<usize>) -> &Self::Output
[src]
impl Index<RangeFrom<usize>> for SoftAsciiStr
[src]
type Output = SoftAsciiStr
The returned type after indexing.
fn index(&self, index: RangeFrom<usize>) -> &Self::Output
[src]
impl Index<RangeFull> for SoftAsciiStr
[src]
type Output = SoftAsciiStr
The returned type after indexing.
fn index(&self, index: RangeFull) -> &Self::Output
[src]
impl Index<RangeTo<usize>> for SoftAsciiStr
[src]
type Output = SoftAsciiStr
The returned type after indexing.
fn index(&self, index: RangeTo<usize>) -> &Self::Output
[src]
impl Ord for SoftAsciiStr
[src]
fn cmp(&self, other: &SoftAsciiStr) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
1.21.0[src]
fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<'a> PartialEq<&'a SoftAsciiStr> for String
[src]
fn eq(&self, other: &&'a SoftAsciiStr) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a> PartialEq<&'a SoftAsciiStr> for OsString
[src]
fn eq(&self, other: &&'a SoftAsciiStr) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a> PartialEq<&'a SoftAsciiStr> for SoftAsciiString
[src]
fn eq(&self, other: &&'a SoftAsciiStr) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a, 'b> PartialEq<&'b SoftAsciiStr> for Cow<'a, SoftAsciiStr>
[src]
fn eq(&self, other: &&'b SoftAsciiStr) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a, 'b> PartialEq<&'b SoftAsciiStr> for Cow<'a, str>
[src]
fn eq(&self, other: &&'b SoftAsciiStr) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a> PartialEq<Cow<'a, SoftAsciiStr>> for SoftAsciiStr
[src]
fn eq(&self, other: &Cow<'a, SoftAsciiStr>) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a, 'b> PartialEq<Cow<'a, SoftAsciiStr>> for &'a SoftAsciiStr
[src]
fn eq(&self, other: &Cow<'a, SoftAsciiStr>) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a> PartialEq<Cow<'a, str>> for SoftAsciiStr
[src]
fn eq(&self, other: &Cow<'a, str>) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a, 'b> PartialEq<Cow<'b, str>> for &'a SoftAsciiStr
[src]
fn eq(&self, other: &Cow<'b, str>) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialEq<OsStr> for SoftAsciiStr
[src]
impl PartialEq<OsString> for SoftAsciiStr
[src]
impl<'a> PartialEq<OsString> for &'a SoftAsciiStr
[src]
impl PartialEq<SoftAsciiStr> for SoftAsciiStr
[src]
fn eq(&self, other: &SoftAsciiStr) -> bool
[src]
fn ne(&self, other: &SoftAsciiStr) -> bool
[src]
impl PartialEq<SoftAsciiStr> for String
[src]
fn eq(&self, other: &SoftAsciiStr) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a> PartialEq<SoftAsciiStr> for str
[src]
fn eq(&self, other: &SoftAsciiStr) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a> PartialEq<SoftAsciiStr> for Cow<'a, SoftAsciiStr>
[src]
fn eq(&self, other: &SoftAsciiStr) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a> PartialEq<SoftAsciiStr> for Cow<'a, str>
[src]
fn eq(&self, other: &SoftAsciiStr) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialEq<SoftAsciiStr> for OsString
[src]
fn eq(&self, other: &SoftAsciiStr) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialEq<SoftAsciiStr> for OsStr
[src]
fn eq(&self, other: &SoftAsciiStr) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialEq<SoftAsciiString> for SoftAsciiStr
[src]
fn eq(&self, other: &SoftAsciiString) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a> PartialEq<SoftAsciiString> for &'a SoftAsciiStr
[src]
fn eq(&self, other: &SoftAsciiString) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialEq<String> for SoftAsciiStr
[src]
impl<'a> PartialEq<String> for &'a SoftAsciiStr
[src]
impl PartialEq<str> for SoftAsciiStr
[src]
impl PartialOrd<SoftAsciiStr> for SoftAsciiStr
[src]
fn partial_cmp(&self, other: &SoftAsciiStr) -> Option<Ordering>
[src]
fn lt(&self, other: &SoftAsciiStr) -> bool
[src]
fn le(&self, other: &SoftAsciiStr) -> bool
[src]
fn gt(&self, other: &SoftAsciiStr) -> bool
[src]
fn ge(&self, other: &SoftAsciiStr) -> bool
[src]
impl StructuralEq for SoftAsciiStr
[src]
impl StructuralPartialEq for SoftAsciiStr
[src]
impl ToOwned for SoftAsciiStr
[src]
type Owned = SoftAsciiString
The resulting type after obtaining ownership.
fn to_owned(&self) -> SoftAsciiString
[src]
fn clone_into(&self, target: &mut Self::Owned)
[src]
impl ToSocketAddrs for SoftAsciiStr
[src]
type Iter = IntoIter<SocketAddr>
Returned iterator over socket addresses which this type may correspond to. Read more
fn to_socket_addrs(&self) -> Result<IntoIter<SocketAddr>>
[src]
Auto Trait Implementations
impl RefUnwindSafe for SoftAsciiStr
impl Send for SoftAsciiStr
impl Sync for SoftAsciiStr
impl Unpin for SoftAsciiStr
impl UnwindSafe for SoftAsciiStr
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,