Struct basic_text::TextSubstr[][src]

#[repr(transparent)]
pub struct TextSubstr(_);
Expand description

Text substring slices.

TextSubstr is to TextSubstring as TextStr is to TextString. It is usually used for borrowing, in the form of &TextSubstr.

Implementations

impl TextSubstr[src]

pub fn from_text_bytes(b: &[u8]) -> Result<&Self, TextError>[src]

Converts a slice of bytes to a text string slice.

pub fn from_text(s: &str) -> Result<&Self, TextError>[src]

Converts a string slice to a text string slice.

pub fn from_text_bytes_mut(b: &mut [u8]) -> Result<&mut Self, TextError>[src]

Converts a mutable slice of bytes to a mutable text string slice.

pub fn from_text_mut(s: &mut str) -> Result<&mut Self, TextError>[src]

Converts a mutable string slice to a mutable text string slice.

pub unsafe fn from_text_bytes_unchecked(b: &[u8]) -> &Self[src]

Converts a slice of bytes to a text string slice without checking that the string contains valid Basic Text.

Safety

This function is unsafe because it does not check that the bytes passed to it are valid Basic Text. If this constraint is violated, undefined behavior results, as the rest of this crate assumes that &TextSubstrs are valid Basic Text.

pub unsafe fn from_text_unchecked(s: &str) -> &Self[src]

Converts a string slice to a text string slice without checking that the string contains valid Basic Text.

Safety

This function is unsafe because it does not check that the bytes passed to it are valid Basic Text. If this constraint is violated, undefined behavior results, as the rest of this crate assumes that &TextSubstrs are valid Basic Text.

pub unsafe fn from_text_bytes_unchecked_mut(b: &mut [u8]) -> &mut Self[src]

Converts a slice of bytes to a text string slice without checking that the string contains valid Basic Text; mutable version.

Safety

This function is unsafe because it does not check that the bytes passed to it are valid Basic Text. If this constraint is violated, undefined behavior results, as the rest of this crate assumes that &TextSubstrs are valid Basic Text.

pub unsafe fn from_text_unchecked_mut(s: &mut str) -> &mut Self[src]

Converts a string slice to a text string slice without checking that the string contains valid Basic Text; mutable version.

Safety

This function is unsafe because it does not check that the string passed to it is valid Basic Text. If this constraint is violated, undefined behavior results, as the rest of this crate assumes that &TextSubstrs are valid Basic Text.

pub unsafe fn from_boxed_text_bytes_unchecked(v: Box<[u8]>) -> Box<Self>[src]

Converts a boxed slice of bytes to a boxed text string slice without checking that the string contains valid basic text.

Safety

This function is unsafe because it does not check that the bytes passed to it are valid Basic Text. If this constraint is violated, undefined behavior results, as the rest of this crate assumes that &TextSubstrs are valid Basic Text.

pub unsafe fn from_boxed_text_unchecked(v: Box<str>) -> Box<Self>[src]

Converts a boxed string slice to a boxed text string slice without checking that the string contains valid basic text.

Safety

This function is unsafe because it does not check that the bytes passed to it are valid Basic Text. If this constraint is violated, undefined behavior results, as the rest of this crate assumes that &TextSubstrs are valid Basic Text.

pub const fn len(&self) -> usize[src]

Returns the length of self.

pub const fn is_empty(&self) -> bool[src]

Returns true if self has a length of zero bytes.

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

Converts a text string slice to a byte slice.

pub unsafe fn as_bytes_mut(&mut self) -> &mut [u8][src]

Converts a mutable text string slice to a mutable byte slice.

Safety

The caller must ensure that the content of the slice is valid Basic Text before the borrow ends and the underlying TextSubstr is used.

Use of a TextSubstr whose contents are not valid Basic Text is undefined behavior.

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

Converts a text string slice to a raw pointer.

pub fn as_mut_ptr(&mut self) -> *mut u8[src]

Converts a mutable text string slice to a raw pointer.

pub fn as_str(&self) -> &str[src]

Extracts a UTF-8 string slice containing the entire TextSubstr.

pub fn split_at(&self, mid: usize) -> (&Self, &Self)[src]

Divide one text string slice into two at an index.

pub fn split_at_mut(&mut self, mid: usize) -> (&mut Self, &mut Self)[src]

Divide one mutable text string slice into two at an index.

pub fn chars(&self) -> Chars<'_>[src]

Returns an iterator over the chars of a text string slice.

pub fn char_indices(&self) -> CharIndices<'_>[src]

Returns an iterator over the chars of a text string slice, and their positions.

pub fn bytes(&self) -> Bytes<'_>[src]

An iterator over the bytes of a text string slice.

pub fn lines(&self) -> Lines<'_>[src]

An iterator over the lines of a text string, as text string slices.

TODO: There should be a TextLines which yields &TextSubstrs.

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

Returns an iterator of u16 over the string encoded as Basic Text.

pub fn contains<'a, P>(&'a self, pat: P) -> bool where
    P: Pattern<'a>, 
[src]

Returns true if the given pattern matches a sub-slice of this text string slice.

Returns false if it does not.

pub fn starts_with<'a, P>(&'a self, pat: P) -> bool where
    P: Pattern<'a>, 
[src]

Returns true if the given pattern matches a prefix of this text string slice.

Returns false if it does not.

pub fn ends_with<'a, P>(&'a self, pat: P) -> bool where
    P: Pattern<'a>,
    <P as Pattern<'a>>::Searcher: ReverseSearcher<'a>, 
[src]

Returns true if the given pattern matches a suffix of this text string slice.

Returns false if it does not.

pub fn find<'a, P>(&'a self, pat: P) -> Option<usize> where
    P: Pattern<'a>, 
[src]

Returns the byte index of the first character of this text string slice that matches the pattern.

Returns None if the pattern doesn’t match.

pub fn rfind<'a, P>(&'a self, pat: P) -> Option<usize> where
    P: Pattern<'a>,
    <P as Pattern<'a>>::Searcher: ReverseSearcher<'a>, 
[src]

Returns the byte index for the first character of the rightmost match of the pattern in this text string slice.

Returns None if the pattern doesn’t match.

pub fn matches<'a, P>(&'a self, pat: P) -> Matches<'a, P> where
    P: Pattern<'a>, 
[src]

An iterator over the disjoint matches of a pattern within the given text string slice.

TODO: There should be a TextMatches which yields &TextSubstrs.

pub fn rmatches<'a, P>(&'a self, pat: P) -> RMatches<'a, P> where
    P: Pattern<'a>,
    <P as Pattern<'a>>::Searcher: ReverseSearcher<'a>, 
[src]

An iterator over the disjoint matches of a pattern within this text string slice, yielded in reverse order.

TODO: There should be a TextRMatches which yields &TextSubstrs.

pub fn match_indices<'a, P>(&'a self, pat: P) -> MatchIndices<'a, P> where
    P: Pattern<'a>, 
[src]

An iterator over the disjoint matches of a pattern within this text string slice as well as the index that the match starts at.

TODO: There should be a TextMatchIndices which yields &TextSubstrs.

pub fn rmatch_indices<'a, P>(&'a self, pat: P) -> RMatchIndices<'a, P> where
    P: Pattern<'a>,
    <P as Pattern<'a>>::Searcher: ReverseSearcher<'a>, 
[src]

An iterator over the disjoint matches of a pattern within self, yielded in reverse order along with the index of the match.

TODO: There should be a TextRMatchIndices which yields &TextSubstrs.

pub fn trim(&self) -> &Self[src]

Returns a text string slice with leading and trailing whitespace removed.

pub fn trim_start(&self) -> &Self[src]

Returns a text string slice with leading whitespace removed.

pub fn trim_end(&self) -> &Self[src]

Returns a text string slice with trailing whitespace removed.

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

Parses this text string slice into another type.

pub fn is_ascii(&self) -> bool[src]

Checks if all characters in this text string are within the ASCII range.

pub fn eq_ignore_ascii_case(&self, other: &Self) -> bool[src]

Checks that two text strings are an ASCII case-insensitive match.

pub fn into_boxed_bytes(self: Box<Self>) -> Box<[u8]>[src]

Converts a Box<TextSubstr> into a Box<[u8]> without copying or allocating.

pub fn into_boxed_text(self: Box<Self>) -> Box<str>[src]

Converts a Box<TextSubstr> into a Box<str> without copying or allocating.

pub fn into_string(self: Box<Self>) -> String[src]

Converts a Box<TextSubstr> into a String without copying or allocating.

pub fn into_text_string(self: Box<Self>) -> TextSubstring[src]

Converts a Box<TextSubstr> into a TextSubstring without copying or allocating.

pub fn repeat(&self, n: usize) -> TextSubstring[src]

Creates a new TextSubstring by repeating a string n times.

pub fn escape_debug(&self) -> EscapeDebug<'_>[src]

Return an iterator that escapes each char in self with char::escape_debug.

pub fn escape_default(&self) -> EscapeDefault<'_>[src]

Return an iterator that escapes each char in self with char::escape_default.

pub fn escape_unicode(&self) -> EscapeUnicode<'_>[src]

Return an iterator that escapes each char in self with char::escape_unicode.

Trait Implementations

impl AsMut<TextSubstr> for TextSubstring[src]

fn as_mut(&mut self) -> &mut TextSubstr[src]

Performs the conversion.

impl AsRef<[u8]> for TextSubstr[src]

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

Performs the conversion.

impl AsRef<OsStr> for TextSubstr[src]

fn as_ref(&self) -> &OsStr[src]

Performs the conversion.

impl AsRef<Path> for TextSubstr[src]

fn as_ref(&self) -> &Path[src]

Performs the conversion.

impl AsRef<TextSubstr> for TextString[src]

fn as_ref(&self) -> &TextSubstr[src]

Performs the conversion.

impl AsRef<TextSubstr> for TextStr[src]

fn as_ref(&self) -> &TextSubstr[src]

Performs the conversion.

impl AsRef<TextSubstr> for TextSubstring[src]

fn as_ref(&self) -> &TextSubstr[src]

Performs the conversion.

impl AsRef<TextSubstr> for TextSubstr[src]

fn as_ref(&self) -> &Self[src]

Performs the conversion.

impl AsRef<str> for TextSubstr[src]

fn as_ref(&self) -> &str[src]

Performs the conversion.

impl Borrow<TextSubstr> for TextSubstring[src]

fn borrow(&self) -> &TextSubstr[src]

Immutably borrows from an owned value. Read more

impl BorrowMut<TextSubstr> for TextSubstring[src]

fn borrow_mut(&mut self) -> &mut TextSubstr[src]

Mutably borrows from an owned value. Read more

impl Debug for TextSubstr[src]

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

Formats the value using the given formatter. Read more

impl Default for &TextSubstr[src]

fn default() -> Self[src]

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

impl Default for &mut TextSubstr[src]

fn default() -> Self[src]

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

impl Display for TextSubstr[src]

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

Formats the value using the given formatter. Read more

impl From<&'_ TextSubstr> for TextSubstring[src]

fn from(s: &TextSubstr) -> Self[src]

Performs the conversion.

impl From<&'_ mut TextSubstr> for TextSubstring[src]

fn from(s: &mut TextSubstr) -> Self[src]

Performs the conversion.

impl Hash for TextSubstr[src]

fn hash<__H: Hasher>(&self, state: &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]

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

impl Index<Range<usize>> for TextSubstr[src]

type Output = TextSubstr

The returned type after indexing.

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

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

impl Index<RangeFrom<usize>> for TextSubstr[src]

type Output = TextSubstr

The returned type after indexing.

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

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

impl Index<RangeTo<usize>> for TextSubstr[src]

type Output = TextSubstr

The returned type after indexing.

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

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

impl Ord for TextSubstr[src]

fn cmp(&self, other: &Self) -> Ordering[src]

This method returns an Ordering between self and other. Read more

#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]

Compares and returns the maximum of two values. Read more

#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]

Compares and returns the minimum of two values. Read more

#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]

Restrict a value to a certain interval. Read more

impl<'a> PartialEq<&'a TextSubstr> for TextSubstring[src]

fn eq(&self, other: &&'a TextSubstr) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl<'a> PartialEq<&'a TextSubstr> for TextString[src]

fn eq(&self, other: &&'a TextSubstr) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl<'a, 'b> PartialEq<Cow<'a, TextStr>> for &'b TextSubstr[src]

fn eq(&self, other: &Cow<'a, TextStr>) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl<'a> PartialEq<Cow<'a, TextSubstr>> for TextSubstr[src]

fn eq(&self, other: &Cow<'a, Self>) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl<'a, 'b> PartialEq<Cow<'a, TextSubstr>> for &'b TextSubstr[src]

fn eq(&self, other: &Cow<'a, TextSubstr>) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl<'a, 'b> PartialEq<Cow<'a, str>> for &'b TextSubstr[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

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl<'a> PartialEq<Cow<'a, str>> for TextSubstr[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

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl<'a> PartialEq<String> for &'a TextSubstr[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

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl PartialEq<String> for TextSubstr[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

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl<'a> PartialEq<TextString> for &'a TextSubstr[src]

fn eq(&self, other: &TextString) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl PartialEq<TextString> for TextSubstr[src]

fn eq(&self, other: &TextString) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl PartialEq<TextSubstr> for TextSubstring[src]

fn eq(&self, other: &TextSubstr) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl PartialEq<TextSubstr> for TextString[src]

fn eq(&self, other: &TextSubstr) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl PartialEq<TextSubstr> for TextSubstr[src]

fn eq(&self, other: &TextSubstr) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &TextSubstr) -> bool[src]

This method tests for !=.

impl<'a> PartialEq<TextSubstring> for &'a TextSubstr[src]

fn eq(&self, other: &TextSubstring) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl PartialEq<TextSubstring> for TextSubstr[src]

fn eq(&self, other: &TextSubstring) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl PartialEq<str> for TextSubstr[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

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl PartialOrd<TextSubstr> for TextSubstr[src]

fn partial_cmp(&self, other: &Self) -> Option<Ordering>[src]

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

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl ToOwned for TextSubstr[src]

type Owned = TextSubstring

The resulting type after obtaining ownership.

fn to_owned(&self) -> Self::Owned[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 ToSocketAddrs for TextSubstr[src]

type Iter = IntoIter<SocketAddr>

Returned iterator over socket addresses which this type may correspond to. Read more

fn to_socket_addrs(&self) -> Result<Self::Iter>[src]

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

impl Eq for TextSubstr[src]

impl StructuralEq for TextSubstr[src]

impl StructuralPartialEq for TextSubstr[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> ToString for T where
    T: Display + ?Sized
[src]

pub default fn to_string(&self) -> String[src]

Converts the given value to a String. Read more