Struct basic_text::TextSubstr
source · [−]#[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
sourceimpl TextSubstr
impl TextSubstr
sourcepub fn from_text_bytes(b: &[u8]) -> Result<&Self, TextError>
pub fn from_text_bytes(b: &[u8]) -> Result<&Self, TextError>
Converts a slice of bytes to a text string slice.
sourcepub fn from_text(s: &str) -> Result<&Self, TextError>
pub fn from_text(s: &str) -> Result<&Self, TextError>
Converts a string slice to a text string slice.
sourcepub fn from_text_bytes_mut(b: &mut [u8]) -> Result<&mut Self, TextError>
pub fn from_text_bytes_mut(b: &mut [u8]) -> Result<&mut Self, TextError>
Converts a mutable slice of bytes to a mutable text string slice.
sourcepub fn from_text_mut(s: &mut str) -> Result<&mut Self, TextError>
pub fn from_text_mut(s: &mut str) -> Result<&mut Self, TextError>
Converts a mutable string slice to a mutable text string slice.
sourcepub unsafe fn from_text_bytes_unchecked(b: &[u8]) -> &Self
pub unsafe fn from_text_bytes_unchecked(b: &[u8]) -> &Self
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.
sourcepub unsafe fn from_text_unchecked(s: &str) -> &Self
pub unsafe fn from_text_unchecked(s: &str) -> &Self
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.
sourcepub unsafe fn from_text_bytes_unchecked_mut(b: &mut [u8]) -> &mut Self
pub unsafe fn from_text_bytes_unchecked_mut(b: &mut [u8]) -> &mut Self
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.
sourcepub unsafe fn from_text_unchecked_mut(s: &mut str) -> &mut Self
pub unsafe fn from_text_unchecked_mut(s: &mut str) -> &mut Self
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.
sourcepub unsafe fn from_boxed_text_bytes_unchecked(v: Box<[u8]>) -> Box<Self>
pub unsafe fn from_boxed_text_bytes_unchecked(v: Box<[u8]>) -> Box<Self>
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.
sourcepub unsafe fn from_boxed_text_unchecked(v: Box<str>) -> Box<Self>
pub unsafe fn from_boxed_text_unchecked(v: Box<str>) -> Box<Self>
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.
sourcepub const fn as_bytes(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub const fn as_bytes(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Converts a text string slice to a byte slice.
sourcepub unsafe fn as_bytes_mut(&mut self) -> &mut [u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub unsafe fn as_bytes_mut(&mut self) -> &mut [u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
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.
sourcepub fn as_mut_ptr(&mut self) -> *mut u8
pub fn as_mut_ptr(&mut self) -> *mut u8
Converts a mutable text string slice to a raw pointer.
sourcepub fn split_at(&self, mid: usize) -> (&Self, &Self)
pub fn split_at(&self, mid: usize) -> (&Self, &Self)
Divide one text string slice into two at an index.
sourcepub fn split_at_mut(&mut self, mid: usize) -> (&mut Self, &mut Self)
pub fn split_at_mut(&mut self, mid: usize) -> (&mut Self, &mut Self)
Divide one mutable text string slice into two at an index.
sourcepub fn char_indices(&self) -> CharIndices<'_>
pub fn char_indices(&self) -> CharIndices<'_>
Returns an iterator over the chars of a text string slice, and their
positions.
sourcepub fn lines(&self) -> Lines<'_>
pub fn lines(&self) -> Lines<'_>
An iterator over the lines of a text string, as text string slices.
TODO: There should be a TextLines which yields &TextSubstrs.
sourcepub fn encode_utf16(&self) -> EncodeUtf16<'_>
pub fn encode_utf16(&self) -> EncodeUtf16<'_>
Returns an iterator of u16 over the string encoded as Basic Text.
sourcepub fn contains<'a, P>(&'a self, pat: P) -> bool where
P: Pattern<'a>,
pub fn contains<'a, P>(&'a self, pat: P) -> bool where
P: Pattern<'a>,
Returns true if the given pattern matches a sub-slice of this
text string slice.
Returns false if it does not.
sourcepub fn starts_with<'a, P>(&'a self, pat: P) -> bool where
P: Pattern<'a>,
pub fn starts_with<'a, P>(&'a self, pat: P) -> bool where
P: Pattern<'a>,
Returns true if the given pattern matches a prefix of this
text string slice.
Returns false if it does not.
sourcepub fn ends_with<'a, P>(&'a self, pat: P) -> bool where
P: Pattern<'a>,
<P as Pattern<'a>>::Searcher: ReverseSearcher<'a>,
pub fn ends_with<'a, P>(&'a self, pat: P) -> bool where
P: Pattern<'a>,
<P as Pattern<'a>>::Searcher: ReverseSearcher<'a>,
Returns true if the given pattern matches a suffix of this
text string slice.
Returns false if it does not.
sourcepub fn find<'a, P>(&'a self, pat: P) -> Option<usize> where
P: Pattern<'a>,
pub fn find<'a, P>(&'a self, pat: P) -> Option<usize> where
P: Pattern<'a>,
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.
sourcepub fn rfind<'a, P>(&'a self, pat: P) -> Option<usize> where
P: Pattern<'a>,
<P as Pattern<'a>>::Searcher: ReverseSearcher<'a>,
pub fn rfind<'a, P>(&'a self, pat: P) -> Option<usize> where
P: Pattern<'a>,
<P as Pattern<'a>>::Searcher: ReverseSearcher<'a>,
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.
sourcepub fn matches<'a, P>(&'a self, pat: P) -> Matches<'a, P> where
P: Pattern<'a>,
pub fn matches<'a, P>(&'a self, pat: P) -> Matches<'a, P> where
P: Pattern<'a>,
An iterator over the disjoint matches of a pattern within the given text string slice.
TODO: There should be a TextMatches which yields &TextSubstrs.
sourcepub fn rmatches<'a, P>(&'a self, pat: P) -> RMatches<'a, P> where
P: Pattern<'a>,
<P as Pattern<'a>>::Searcher: ReverseSearcher<'a>,
pub fn rmatches<'a, P>(&'a self, pat: P) -> RMatches<'a, P> where
P: Pattern<'a>,
<P as Pattern<'a>>::Searcher: ReverseSearcher<'a>,
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.
sourcepub fn match_indices<'a, P>(&'a self, pat: P) -> MatchIndices<'a, P> where
P: Pattern<'a>,
pub fn match_indices<'a, P>(&'a self, pat: P) -> MatchIndices<'a, P> where
P: Pattern<'a>,
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.
sourcepub fn rmatch_indices<'a, P>(&'a self, pat: P) -> RMatchIndices<'a, P> where
P: Pattern<'a>,
<P as Pattern<'a>>::Searcher: ReverseSearcher<'a>,
pub fn rmatch_indices<'a, P>(&'a self, pat: P) -> RMatchIndices<'a, P> where
P: Pattern<'a>,
<P as Pattern<'a>>::Searcher: ReverseSearcher<'a>,
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.
sourcepub fn trim(&self) -> &Self
pub fn trim(&self) -> &Self
Returns a text string slice with leading and trailing whitespace removed.
sourcepub fn trim_start(&self) -> &Self
pub fn trim_start(&self) -> &Self
Returns a text string slice with leading whitespace removed.
sourcepub fn parse<F>(&self) -> Result<F, <F as FromStr>::Err> where
F: FromStr,
pub fn parse<F>(&self) -> Result<F, <F as FromStr>::Err> where
F: FromStr,
Parses this text string slice into another type.
sourcepub fn is_ascii(&self) -> bool
pub fn is_ascii(&self) -> bool
Checks if all characters in this text string are within the ASCII range.
sourcepub fn eq_ignore_ascii_case(&self, other: &Self) -> bool
pub fn eq_ignore_ascii_case(&self, other: &Self) -> bool
Checks that two text strings are an ASCII case-insensitive match.
sourcepub fn into_boxed_bytes(self: Box<Self>) -> Box<[u8]>
pub fn into_boxed_bytes(self: Box<Self>) -> Box<[u8]>
Converts a Box<TextSubstr> into a Box<[u8]> without copying or
allocating.
sourcepub fn into_boxed_text(self: Box<Self>) -> Box<str>
pub fn into_boxed_text(self: Box<Self>) -> Box<str>
Converts a Box<TextSubstr> into a Box<str> without copying or
allocating.
sourcepub fn into_string(self: Box<Self>) -> String
pub fn into_string(self: Box<Self>) -> String
Converts a Box<TextSubstr> into a String without copying or
allocating.
sourcepub fn into_text_string(self: Box<Self>) -> TextSubstring
pub fn into_text_string(self: Box<Self>) -> TextSubstring
Converts a Box<TextSubstr> into a TextSubstring without copying or
allocating.
sourcepub fn repeat(&self, n: usize) -> TextSubstring
pub fn repeat(&self, n: usize) -> TextSubstring
Creates a new TextSubstring by repeating a string n times.
sourcepub fn escape_debug(&self) -> EscapeDebug<'_>
pub fn escape_debug(&self) -> EscapeDebug<'_>
Return an iterator that escapes each char in self with
char::escape_debug.
sourcepub fn escape_default(&self) -> EscapeDefault<'_>
pub fn escape_default(&self) -> EscapeDefault<'_>
Return an iterator that escapes each char in self with
char::escape_default.
sourcepub fn escape_unicode(&self) -> EscapeUnicode<'_>
pub fn escape_unicode(&self) -> EscapeUnicode<'_>
Return an iterator that escapes each char in self with
char::escape_unicode.
Trait Implementations
sourceimpl AsMut<TextSubstr> for TextSubstring
impl AsMut<TextSubstr> for TextSubstring
sourcefn as_mut(&mut self) -> &mut TextSubstr
fn as_mut(&mut self) -> &mut TextSubstr
Converts this type into a mutable reference of the (usually inferred) input type.
sourceimpl AsRef<[u8]> for TextSubstr
impl AsRef<[u8]> for TextSubstr
sourceimpl AsRef<OsStr> for TextSubstr
impl AsRef<OsStr> for TextSubstr
sourceimpl AsRef<Path> for TextSubstr
impl AsRef<Path> for TextSubstr
sourceimpl AsRef<TextSubstr> for TextString
impl AsRef<TextSubstr> for TextString
sourcefn as_ref(&self) -> &TextSubstr
fn as_ref(&self) -> &TextSubstr
Converts this type into a shared reference of the (usually inferred) input type.
sourceimpl AsRef<TextSubstr> for TextStr
impl AsRef<TextSubstr> for TextStr
sourcefn as_ref(&self) -> &TextSubstr
fn as_ref(&self) -> &TextSubstr
Converts this type into a shared reference of the (usually inferred) input type.
sourceimpl AsRef<TextSubstr> for TextSubstring
impl AsRef<TextSubstr> for TextSubstring
sourcefn as_ref(&self) -> &TextSubstr
fn as_ref(&self) -> &TextSubstr
Converts this type into a shared reference of the (usually inferred) input type.
sourceimpl AsRef<TextSubstr> for TextSubstr
impl AsRef<TextSubstr> for TextSubstr
sourceimpl AsRef<str> for TextSubstr
impl AsRef<str> for TextSubstr
sourceimpl Borrow<TextSubstr> for TextSubstring
impl Borrow<TextSubstr> for TextSubstring
sourcefn borrow(&self) -> &TextSubstr
fn borrow(&self) -> &TextSubstr
Immutably borrows from an owned value. Read more
sourceimpl BorrowMut<TextSubstr> for TextSubstring
impl BorrowMut<TextSubstr> for TextSubstring
sourcefn borrow_mut(&mut self) -> &mut TextSubstr
fn borrow_mut(&mut self) -> &mut TextSubstr
Mutably borrows from an owned value. Read more
sourceimpl Clone for Box<TextSubstr>
impl Clone for Box<TextSubstr>
sourceimpl Debug for TextSubstr
impl Debug for TextSubstr
sourceimpl Default for &TextSubstr
impl Default for &TextSubstr
sourceimpl Default for &mut TextSubstr
impl Default for &mut TextSubstr
sourceimpl Default for Box<TextSubstr>
impl Default for Box<TextSubstr>
sourceimpl Display for TextSubstr
impl Display for TextSubstr
sourceimpl From<&'_ TextSubstr> for TextSubstring
impl From<&'_ TextSubstr> for TextSubstring
sourcefn from(s: &TextSubstr) -> Self
fn from(s: &TextSubstr) -> Self
Converts to this type from the input type.
sourceimpl From<&'_ TextSubstr> for Box<TextSubstr>
impl From<&'_ TextSubstr> for Box<TextSubstr>
sourcefn from(s: &TextSubstr) -> Self
fn from(s: &TextSubstr) -> Self
Converts to this type from the input type.
sourceimpl From<&'_ mut TextSubstr> for TextSubstring
impl From<&'_ mut TextSubstr> for TextSubstring
sourcefn from(s: &mut TextSubstr) -> Self
fn from(s: &mut TextSubstr) -> Self
Converts to this type from the input type.
sourceimpl From<Cow<'_, TextSubstr>> for Box<TextSubstr>
impl From<Cow<'_, TextSubstr>> for Box<TextSubstr>
sourcefn from(cow: Cow<'_, TextSubstr>) -> Self
fn from(cow: Cow<'_, TextSubstr>) -> Self
Converts to this type from the input type.
sourceimpl From<TextSubstring> for Box<TextSubstr>
impl From<TextSubstring> for Box<TextSubstr>
sourcefn from(s: TextSubstring) -> Self
fn from(s: TextSubstring) -> Self
Converts to this type from the input type.
sourceimpl Hash for TextSubstr
impl Hash for TextSubstr
sourceimpl Index<Range<usize>> for TextSubstr
impl Index<Range<usize>> for TextSubstr
sourceimpl Index<RangeFrom<usize>> for TextSubstr
impl Index<RangeFrom<usize>> for TextSubstr
sourceimpl Index<RangeTo<usize>> for TextSubstr
impl Index<RangeTo<usize>> for TextSubstr
sourceimpl Ord for TextSubstr
impl Ord for TextSubstr
sourceimpl<'a> PartialEq<&'a TextSubstr> for String
impl<'a> PartialEq<&'a TextSubstr> for String
sourceimpl<'a> PartialEq<&'a TextSubstr> for TextSubstring
impl<'a> PartialEq<&'a TextSubstr> for TextSubstring
sourceimpl<'a> PartialEq<&'a TextSubstr> for TextString
impl<'a> PartialEq<&'a TextSubstr> for TextString
sourceimpl<'a, 'b> PartialEq<&'b TextSubstr> for Cow<'a, str>
impl<'a, 'b> PartialEq<&'b TextSubstr> for Cow<'a, str>
sourceimpl<'a, 'b> PartialEq<&'b TextSubstr> for Cow<'a, TextSubstr>
impl<'a, 'b> PartialEq<&'b TextSubstr> for Cow<'a, TextSubstr>
sourceimpl<'a, 'b> PartialEq<&'b TextSubstr> for Cow<'a, TextStr>
impl<'a, 'b> PartialEq<&'b TextSubstr> for Cow<'a, TextStr>
sourceimpl<'a, 'b> PartialEq<Cow<'a, TextStr>> for &'b TextSubstr
impl<'a, 'b> PartialEq<Cow<'a, TextStr>> for &'b TextSubstr
sourceimpl<'a> PartialEq<Cow<'a, TextSubstr>> for TextSubstr
impl<'a> PartialEq<Cow<'a, TextSubstr>> for TextSubstr
sourceimpl<'a, 'b> PartialEq<Cow<'a, TextSubstr>> for &'b TextSubstr
impl<'a, 'b> PartialEq<Cow<'a, TextSubstr>> for &'b TextSubstr
sourceimpl<'a, 'b> PartialEq<Cow<'a, str>> for &'b TextSubstr
impl<'a, 'b> PartialEq<Cow<'a, str>> for &'b TextSubstr
sourceimpl<'a> PartialEq<Cow<'a, str>> for TextSubstr
impl<'a> PartialEq<Cow<'a, str>> for TextSubstr
sourceimpl<'a> PartialEq<String> for &'a TextSubstr
impl<'a> PartialEq<String> for &'a TextSubstr
sourceimpl PartialEq<String> for TextSubstr
impl PartialEq<String> for TextSubstr
sourceimpl<'a> PartialEq<TextString> for &'a TextSubstr
impl<'a> PartialEq<TextString> for &'a TextSubstr
sourceimpl PartialEq<TextString> for TextSubstr
impl PartialEq<TextString> for TextSubstr
sourceimpl PartialEq<TextSubstr> for str
impl PartialEq<TextSubstr> for str
sourceimpl<'a> PartialEq<TextSubstr> for Cow<'a, TextSubstr>
impl<'a> PartialEq<TextSubstr> for Cow<'a, TextSubstr>
sourceimpl<'a> PartialEq<TextSubstr> for Cow<'a, str>
impl<'a> PartialEq<TextSubstr> for Cow<'a, str>
sourceimpl PartialEq<TextSubstr> for TextSubstring
impl PartialEq<TextSubstr> for TextSubstring
sourceimpl PartialEq<TextSubstr> for String
impl PartialEq<TextSubstr> for String
sourceimpl<'a> PartialEq<TextSubstr> for Cow<'a, TextStr>
impl<'a> PartialEq<TextSubstr> for Cow<'a, TextStr>
sourceimpl PartialEq<TextSubstr> for TextString
impl PartialEq<TextSubstr> for TextString
sourceimpl PartialEq<TextSubstr> for TextSubstr
impl PartialEq<TextSubstr> for TextSubstr
sourcefn eq(&self, other: &TextSubstr) -> bool
fn eq(&self, other: &TextSubstr) -> bool
This method tests for self and other values to be equal, and is used
by ==. Read more
sourcefn ne(&self, other: &TextSubstr) -> bool
fn ne(&self, other: &TextSubstr) -> bool
This method tests for !=.
sourceimpl<'a> PartialEq<TextSubstring> for &'a TextSubstr
impl<'a> PartialEq<TextSubstring> for &'a TextSubstr
sourceimpl PartialEq<TextSubstring> for TextSubstr
impl PartialEq<TextSubstring> for TextSubstr
sourceimpl PartialEq<str> for TextSubstr
impl PartialEq<str> for TextSubstr
sourceimpl PartialOrd<TextSubstr> for TextSubstr
impl PartialOrd<TextSubstr> for TextSubstr
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self and other values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
sourceimpl ToOwned for TextSubstr
impl ToOwned for TextSubstr
type Owned = TextSubstring
type Owned = TextSubstring
The resulting type after obtaining ownership.
sourcefn to_owned(&self) -> Self::Owned
fn to_owned(&self) -> Self::Owned
Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · sourcefn clone_into(&self, target: &mut Self::Owned)
fn clone_into(&self, target: &mut Self::Owned)
Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl ToSocketAddrs for TextSubstr
impl ToSocketAddrs for TextSubstr
type Iter = IntoIter<SocketAddr, Global>
type Iter = IntoIter<SocketAddr, Global>
Returned iterator over socket addresses which this type may correspond to. Read more
sourcefn to_socket_addrs(&self) -> Result<Self::Iter>
fn to_socket_addrs(&self) -> Result<Self::Iter>
Converts this object to an iterator of resolved SocketAddrs. Read more