Struct soft_ascii_string::SoftAsciiStr
[−]
[src]
pub struct SoftAsciiStr(_);
A str
wrapper adding a "is us-ascii" soft constraint.
This means that it should be ascii but is not guranteed to be ascii. Which means non ascii chars are not a safty issue just a potential bug.
This is usefull for siturations where: 1. you would have many unsafe from str conversions/"unessesary" checks with a strict AsciiStr 2. you rarely have to strictly rely on the value beeing 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]
fn from_str_unchecked(s: &str) -> &SoftAsciiStr
[src]
fn from_str_unchecked_mut(s: &mut str) -> &mut SoftAsciiStr
[src]
fn from_str(source: &str) -> Result<&Self, FromSourceError<&str>>
[src]
fn revalidate_soft_constraint(&self) -> Result<&Self, FromSourceError<&str>>
[src]
reruns checks if the "is us-ascii" soft constraint is still valid
fn as_str(&self) -> &str
[src]
fn into_soft_ascii_string(self: Box<SoftAsciiStr>) -> SoftAsciiString
[src]
fn from_boxed_str(bs: Box<str>) -> Box<SoftAsciiStr>
[src]
fn into_boxed_str(self: Box<SoftAsciiStr>) -> Box<str>
[src]
fn lines(&self) -> SoftAsciiLines
[src]
fn split_whitespace(&self) -> SoftAsciiSplitWhitespace
[src]
fn char_indices(&self) -> SoftAsciiCharIndices
[src]
fn chars(&self) -> SoftAsciiChars
[src]
fn split_at(&self, mid: usize) -> (&SoftAsciiStr, &SoftAsciiStr)
[src]
unsafe fn slice_unchecked(&self, begin: usize, end: usize) -> &SoftAsciiStr
[src]
fn inner_str_mut(&mut self) -> &mut str
[src]
returns a mutable str
reference to the inner buffer
Soft Constriant
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 brakage of the
soft constraint that the data should be ascii.
fn parse<F>(&self) -> Result<F, <F as FromStr>::Err> where
F: FromStr,
[src]
F: FromStr,
impl SoftAsciiStr
[src]
fn to_lowercase(&self) -> SoftAsciiString
[src]
impl SoftAsciiStr
[src]
fn to_uppercase(&self) -> SoftAsciiString
[src]
impl SoftAsciiStr
[src]
fn repeat(&self, n: usize) -> SoftAsciiString
[src]
impl SoftAsciiStr
[src]
fn trim_right(&self) -> &SoftAsciiStr
[src]
fn trim_left(&self) -> &SoftAsciiStr
[src]
fn trim(&self) -> &SoftAsciiStr
[src]
impl SoftAsciiStr
[src]
fn len(&self) -> usize
[src]
fn is_empty(&self) -> bool
[src]
fn is_char_boundary(&self, index: usize) -> bool
[src]
fn as_ptr(&self) -> *const u8
[src]
fn encode_utf16(&self) -> EncodeUtf16
[src]
fn is_ascii(&self) -> bool
[src]
fn as_bytes(&self) -> &[u8]
[src]
Trait Implementations
impl Debug for SoftAsciiStr
[src]
impl PartialEq for SoftAsciiStr
[src]
fn eq(&self, __arg_0: &SoftAsciiStr) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &SoftAsciiStr) -> bool
[src]
This method tests for !=
.
impl Eq for SoftAsciiStr
[src]
impl PartialOrd for SoftAsciiStr
[src]
fn partial_cmp(&self, __arg_0: &SoftAsciiStr) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &SoftAsciiStr) -> bool
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &SoftAsciiStr) -> bool
[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &SoftAsciiStr) -> bool
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &SoftAsciiStr) -> bool
[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Ord for SoftAsciiStr
[src]
fn cmp(&self, __arg_0: &SoftAsciiStr) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.22.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.22.0[src]
Compares and returns the minimum of two values. Read more
impl Hash for SoftAsciiStr
[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
[src]
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl AsRef<SoftAsciiStr> for SoftAsciiStr
[src]
impl AsRef<str> for SoftAsciiStr
[src]
impl AsRef<[u8]> for SoftAsciiStr
[src]
impl<'a> Default for &'a SoftAsciiStr
[src]
fn default() -> &'a SoftAsciiStr
[src]
Returns the "default value" for a type. Read more
impl Display for SoftAsciiStr
[src]
fn fmt(&self, fter: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Index<Range<usize>> for SoftAsciiStr
[src]
type Output = SoftAsciiStr
The returned type after indexing.
fn index(&self, index: Range<usize>) -> &Self::Output
[src]
Performs the indexing (container[index]
) operation.
impl Index<RangeFrom<usize>> for SoftAsciiStr
[src]
type Output = SoftAsciiStr
The returned type after indexing.
fn index(&self, index: RangeFrom<usize>) -> &Self::Output
[src]
Performs the indexing (container[index]
) operation.
impl Index<RangeTo<usize>> for SoftAsciiStr
[src]
type Output = SoftAsciiStr
The returned type after indexing.
fn index(&self, index: RangeTo<usize>) -> &Self::Output
[src]
Performs the indexing (container[index]
) operation.
impl Index<RangeFull> for SoftAsciiStr
[src]
type Output = SoftAsciiStr
The returned type after indexing.
fn index(&self, index: RangeFull) -> &Self::Output
[src]
Performs the indexing (container[index]
) operation.
impl ToOwned for SoftAsciiStr
[src]
type Owned = SoftAsciiString
fn to_owned(&self) -> SoftAsciiString
[src]
Creates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut Self::Owned)
[src]
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl PartialEq<SoftAsciiString> for SoftAsciiStr
[src]
fn eq(&self, other: &SoftAsciiString) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<'a> PartialEq<SoftAsciiString> for &'a SoftAsciiStr
[src]
fn eq(&self, other: &SoftAsciiString) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl PartialEq<String> for SoftAsciiStr
[src]
fn eq(&self, other: &String) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<'a> PartialEq<String> for &'a SoftAsciiStr
[src]
fn eq(&self, other: &String) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl PartialEq<str> for SoftAsciiStr
[src]
fn eq(&self, other: &str) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<'a> PartialEq<Cow<'a, SoftAsciiStr>> for SoftAsciiStr
[src]
fn eq(&self, other: &Cow<'a, SoftAsciiStr>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<'a, 'b> PartialEq<Cow<'a, SoftAsciiStr>> for &'a SoftAsciiStr
[src]
fn eq(&self, other: &Cow<'a, SoftAsciiStr>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<'a> PartialEq<Cow<'a, str>> for SoftAsciiStr
[src]
fn eq(&self, other: &Cow<'a, str>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<'a, 'b> PartialEq<Cow<'b, str>> for &'a SoftAsciiStr
[src]
fn eq(&self, other: &Cow<'b, str>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl PartialEq<OsString> for SoftAsciiStr
[src]
fn eq(&self, other: &OsString) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<'a> PartialEq<OsString> for &'a SoftAsciiStr
[src]
fn eq(&self, other: &OsString) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl PartialEq<OsStr> for SoftAsciiStr
[src]
fn eq(&self, other: &OsStr) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl AsRef<OsStr> for SoftAsciiStr
[src]
impl AsRef<Path> for SoftAsciiStr
[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]
Converts this object to an iterator of resolved SocketAddr
s. Read more