Struct SoftAsciiString

Source
pub struct SoftAsciiString(/* private fields */);
Expand description

a String wrapper with an additional “is us-ascii” soft constraint

Implementations§

Source§

impl SoftAsciiString

Source

pub fn from_unchecked<S: Into<String>>(s: S) -> Self

Source

pub fn from_string_unchecked<S: Into<String>>(s: S) -> Self

👎Deprecated since 1.0.0: use from_unchecked
Source

pub fn from_string<S>(source: S) -> Result<Self, FromSourceError<S>>
where S: Debug + AsRef<str> + Into<String>,

Source

pub fn new() -> Self

Source

pub fn with_capacity(cap: usize) -> Self

Source

pub fn revalidate_soft_constraint(self) -> Result<SoftAsciiString, String>

Source

pub fn inner_string_mut(&mut self) -> &mut String

Source

pub fn inner_string(&self) -> &String

Source

pub fn push_str(&mut self, other: &SoftAsciiStr)

Source

pub fn into_bytes(self) -> Vec<u8>

Source

pub fn push(&mut self, ch: SoftAsciiChar)

Source

pub fn pop(&mut self) -> Option<SoftAsciiChar>

Source

pub fn remove(&mut self, idx: usize) -> SoftAsciiChar

Source

pub fn insert(&mut self, idx: usize, ch: SoftAsciiChar)

Source

pub fn insert_str(&mut self, idx: usize, string: &SoftAsciiStr)

Source

pub fn as_soft_ascii_str(&self) -> &SoftAsciiStr

Source

pub fn as_soft_ascii_str_mut(&mut self) -> &mut SoftAsciiStr

Source

pub fn split_off(&mut self, at: usize) -> SoftAsciiString

Source

pub fn into_boxed_soft_ascii_str(self) -> Box<SoftAsciiStr>

Source

pub fn into_boxed_str(self) -> Box<str>

Source

pub fn is_ascii(&self) -> bool

Source§

impl SoftAsciiString

Source

pub fn as_bytes(&self) -> &[u8]

Source

pub fn capacity(&self) -> usize

Source

pub fn len(&self) -> usize

Source

pub fn as_str(&self) -> &str

Source

pub fn is_empty(&self) -> bool

Source§

impl SoftAsciiString

Source

pub fn reserve(&mut self, additional: usize)

Source

pub fn reserve_exact(&mut self, additional: usize)

Source

pub fn shrink_to_fit(&mut self)

Source

pub fn truncate(&mut self, new_len: usize)

Source

pub fn clear(&mut self)

Methods from Deref<Target = SoftAsciiStr>§

Source

pub fn revalidate_soft_constraint(&self) -> Result<&Self, FromSourceError<&str>>

reruns checks if the “is us-ascii” soft constraint is still valid

Source

pub fn as_str(&self) -> &str

Source

pub fn lines(&self) -> SoftAsciiLines<'_>

Source

pub fn split_whitespace(&self) -> SoftAsciiSplitWhitespace<'_>

Source

pub fn char_indices(&self) -> SoftAsciiCharIndices<'_>

Source

pub fn chars(&self) -> SoftAsciiChars<'_>

Source

pub fn split_at(&self, mid: usize) -> (&SoftAsciiStr, &SoftAsciiStr)

Source

pub unsafe fn slice_unchecked(&self, begin: usize, end: usize) -> &SoftAsciiStr

👎Deprecated since 1.1.0: deprecated in std
Source

pub unsafe fn get_unchecked<I>(&self, index: I) -> &SoftAsciiStr
where 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.

Source

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.

Source

pub fn parse<F>(&self) -> Result<F, <F as FromStr>::Err>
where F: FromStr,

Source

pub fn to_lowercase(&self) -> SoftAsciiString

Source

pub fn to_uppercase(&self) -> SoftAsciiString

Source

pub fn repeat(&self, n: usize) -> SoftAsciiString

Source

pub fn trim_right(&self) -> &SoftAsciiStr

👎Deprecated since 1.1.0: deprecated in std
Source

pub fn trim_left(&self) -> &SoftAsciiStr

👎Deprecated since 1.1.0: deprecated in std
Source

pub fn trim_end(&self) -> &SoftAsciiStr

Source

pub fn trim_start(&self) -> &SoftAsciiStr

Source

pub fn trim(&self) -> &SoftAsciiStr

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn is_char_boundary(&self, index: usize) -> bool

Source

pub fn as_ptr(&self) -> *const u8

Source

pub fn encode_utf16(&self) -> EncodeUtf16<'_>

Source

pub fn is_ascii(&self) -> bool

Source

pub fn as_bytes(&self) -> &[u8]

Trait Implementations§

Source§

impl<'a> Add<&'a SoftAsciiStr> for SoftAsciiString

Source§

type Output = SoftAsciiString

The resulting type after applying the + operator.
Source§

fn add(self, other: &'a SoftAsciiStr) -> Self

Performs the + operation. Read more
Source§

impl<'a> AddAssign<&'a SoftAsciiStr> for SoftAsciiString

Source§

fn add_assign(&mut self, other: &'a SoftAsciiStr)

Performs the += operation. Read more
Source§

impl AsRef<[u8]> for SoftAsciiString

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<OsStr> for SoftAsciiString

Source§

fn as_ref(&self) -> &OsStr

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Path> for SoftAsciiString

Source§

fn as_ref(&self) -> &Path

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<SoftAsciiStr> for SoftAsciiString

Source§

fn as_ref(&self) -> &SoftAsciiStr

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<str> for SoftAsciiString

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<SoftAsciiStr> for SoftAsciiString

Source§

fn borrow(&self) -> &SoftAsciiStr

Immutably borrows from an owned value. Read more
Source§

impl Borrow<str> for SoftAsciiString

Source§

fn borrow(&self) -> &str

Immutably borrows from an owned value. Read more
Source§

impl Clone for SoftAsciiString

Source§

fn clone(&self) -> SoftAsciiString

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SoftAsciiString

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SoftAsciiString

Source§

fn default() -> SoftAsciiString

Returns the “default value” for a type. Read more
Source§

impl Deref for SoftAsciiString

Source§

type Target = SoftAsciiStr

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for SoftAsciiString

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl Display for SoftAsciiString

Source§

fn fmt(&self, fter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Extend<&'a SoftAsciiChar> for SoftAsciiString

Source§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = &'a SoftAsciiChar>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<'a> Extend<&'a SoftAsciiStr> for SoftAsciiString

Source§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = &'a SoftAsciiStr>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<'a> Extend<Cow<'a, SoftAsciiStr>> for SoftAsciiString

Source§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = Cow<'a, SoftAsciiStr>>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl Extend<SoftAsciiChar> for SoftAsciiString

Source§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = SoftAsciiChar>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl Extend<SoftAsciiString> for SoftAsciiString

Source§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = SoftAsciiString>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<'a> From<&'a SoftAsciiStr> for SoftAsciiString

Source§

fn from(s: &'a SoftAsciiStr) -> Self

Converts to this type from the input type.
Source§

impl From<Box<SoftAsciiStr>> for SoftAsciiString

Source§

fn from(b: Box<SoftAsciiStr>) -> SoftAsciiString

Converts to this type from the input type.
Source§

impl<'a> From<Cow<'a, SoftAsciiStr>> for SoftAsciiString

Source§

fn from(cow: Cow<'a, SoftAsciiStr>) -> Self

Converts to this type from the input type.
Source§

impl<'a> FromIterator<&'a SoftAsciiChar> for SoftAsciiString

Source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = &'a SoftAsciiChar>,

Creates a value from an iterator. Read more
Source§

impl<'a> FromIterator<&'a SoftAsciiStr> for SoftAsciiString

Source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = &'a SoftAsciiStr>,

Creates a value from an iterator. Read more
Source§

impl<'a> FromIterator<Cow<'a, SoftAsciiStr>> for SoftAsciiString

Source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = Cow<'a, SoftAsciiStr>>,

Creates a value from an iterator. Read more
Source§

impl FromIterator<SoftAsciiChar> for SoftAsciiString

Source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = SoftAsciiChar>,

Creates a value from an iterator. Read more
Source§

impl FromIterator<SoftAsciiString> for SoftAsciiString

Source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = SoftAsciiString>,

Creates a value from an iterator. Read more
Source§

impl FromStr for SoftAsciiString

Source§

type Err = StringFromStrError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for SoftAsciiString

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Index<Range<usize>> for SoftAsciiString

Source§

type Output = SoftAsciiStr

The returned type after indexing.
Source§

fn index(&self, index: Range<usize>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<RangeFrom<usize>> for SoftAsciiString

Source§

type Output = SoftAsciiStr

The returned type after indexing.
Source§

fn index(&self, index: RangeFrom<usize>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<RangeFull> for SoftAsciiString

Source§

type Output = SoftAsciiStr

The returned type after indexing.
Source§

fn index(&self, index: RangeFull) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<RangeTo<usize>> for SoftAsciiString

Source§

type Output = SoftAsciiStr

The returned type after indexing.
Source§

fn index(&self, index: RangeTo<usize>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl IndexMut<Range<usize>> for SoftAsciiString

Source§

fn index_mut(&mut self, index: Range<usize>) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IndexMut<RangeFrom<usize>> for SoftAsciiString

Source§

fn index_mut(&mut self, index: RangeFrom<usize>) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IndexMut<RangeFull> for SoftAsciiString

Source§

fn index_mut(&mut self, index: RangeFull) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IndexMut<RangeTo<usize>> for SoftAsciiString

Source§

fn index_mut(&mut self, index: RangeTo<usize>) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl Into<String> for SoftAsciiString

Source§

fn into(self) -> String

Converts this type into the (usually inferred) input type.
Source§

impl Into<Vec<u8>> for SoftAsciiString

Source§

fn into(self) -> Vec<u8>

Converts this type into the (usually inferred) input type.
Source§

impl Ord for SoftAsciiString

Source§

fn cmp(&self, other: &SoftAsciiString) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<'a> PartialEq<&'a SoftAsciiStr> for SoftAsciiString

Source§

fn eq(&self, other: &&'a SoftAsciiStr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> PartialEq<&'a str> for SoftAsciiString

Source§

fn eq(&self, other: &&'a str) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> PartialEq<Cow<'a, SoftAsciiStr>> for SoftAsciiString

Source§

fn eq(&self, other: &Cow<'a, SoftAsciiStr>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> PartialEq<Cow<'a, str>> for SoftAsciiString

Source§

fn eq(&self, other: &Cow<'a, str>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> PartialEq<SoftAsciiString> for &'a SoftAsciiStr

Source§

fn eq(&self, other: &SoftAsciiString) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> PartialEq<SoftAsciiString> for &'a str

Source§

fn eq(&self, other: &SoftAsciiString) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> PartialEq<SoftAsciiString> for Cow<'a, SoftAsciiStr>

Source§

fn eq(&self, other: &SoftAsciiString) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> PartialEq<SoftAsciiString> for Cow<'a, str>

Source§

fn eq(&self, other: &SoftAsciiString) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<SoftAsciiString> for SoftAsciiStr

Source§

fn eq(&self, other: &SoftAsciiString) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<SoftAsciiString> for String

Source§

fn eq(&self, other: &SoftAsciiString) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<SoftAsciiString> for str

Source§

fn eq(&self, other: &SoftAsciiString) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<String> for SoftAsciiString

Source§

fn eq(&self, other: &String) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<str> for SoftAsciiString

Source§

fn eq(&self, other: &str) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for SoftAsciiString

Source§

fn eq(&self, other: &SoftAsciiString) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for SoftAsciiString

Source§

fn partial_cmp(&self, other: &SoftAsciiString) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl ToSocketAddrs for SoftAsciiString

Source§

type Iter = IntoIter<SocketAddr>

Returned iterator over socket addresses which this type may correspond to.
Source§

fn to_socket_addrs(&self) -> Result<IntoIter<SocketAddr>>

Converts this object to an iterator of resolved SocketAddrs. Read more
Source§

impl Eq for SoftAsciiString

Source§

impl StructuralPartialEq for SoftAsciiString

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.