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§
source§impl 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 &TextSubstr
s
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 &TextSubstr
s
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 &TextSubstr
s
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
&TextSubstr
s 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 &TextSubstr
s
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 &TextSubstr
s
are valid Basic Text.
sourcepub unsafe fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
pub unsafe fn as_bytes_mut(&mut self) -> &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 char
s 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 &TextSubstr
s.
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) -> boolwhere
P: Pattern<'a>,
pub fn contains<'a, P>(&'a self, pat: P) -> boolwhere 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) -> boolwhere
P: Pattern<'a>,
pub fn starts_with<'a, P>(&'a self, pat: P) -> boolwhere 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) -> boolwhere
P: Pattern<'a>,
<P as Pattern<'a>>::Searcher: ReverseSearcher<'a>,
pub fn ends_with<'a, P>(&'a self, pat: P) -> boolwhere 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 &TextSubstr
s.
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 &TextSubstr
s.
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 &TextSubstr
s.
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
&TextSubstr
s.
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§
source§impl AsMut<TextSubstr> for TextSubstring
impl AsMut<TextSubstr> for TextSubstring
source§fn as_mut(&mut self) -> &mut TextSubstr
fn as_mut(&mut self) -> &mut TextSubstr
source§impl AsRef<[u8]> for TextSubstr
impl AsRef<[u8]> for TextSubstr
source§impl AsRef<OsStr> for TextSubstr
impl AsRef<OsStr> for TextSubstr
source§impl AsRef<Path> for TextSubstr
impl AsRef<Path> for TextSubstr
source§impl AsRef<TextSubstr> for TextStr
impl AsRef<TextSubstr> for TextStr
source§fn as_ref(&self) -> &TextSubstr
fn as_ref(&self) -> &TextSubstr
source§impl AsRef<TextSubstr> for TextString
impl AsRef<TextSubstr> for TextString
source§fn as_ref(&self) -> &TextSubstr
fn as_ref(&self) -> &TextSubstr
source§impl AsRef<TextSubstr> for TextSubstr
impl AsRef<TextSubstr> for TextSubstr
source§impl AsRef<TextSubstr> for TextSubstring
impl AsRef<TextSubstr> for TextSubstring
source§fn as_ref(&self) -> &TextSubstr
fn as_ref(&self) -> &TextSubstr
source§impl AsRef<str> for TextSubstr
impl AsRef<str> for TextSubstr
source§impl Borrow<TextSubstr> for TextSubstring
impl Borrow<TextSubstr> for TextSubstring
source§fn borrow(&self) -> &TextSubstr
fn borrow(&self) -> &TextSubstr
source§impl BorrowMut<TextSubstr> for TextSubstring
impl BorrowMut<TextSubstr> for TextSubstring
source§fn borrow_mut(&mut self) -> &mut TextSubstr
fn borrow_mut(&mut self) -> &mut TextSubstr
source§impl Clone for Box<TextSubstr>
impl Clone for Box<TextSubstr>
source§impl Debug for TextSubstr
impl Debug for TextSubstr
source§impl Default for &TextSubstr
impl Default for &TextSubstr
source§impl Default for &mut TextSubstr
impl Default for &mut TextSubstr
source§impl Default for Box<TextSubstr>
impl Default for Box<TextSubstr>
source§impl Display for TextSubstr
impl Display for TextSubstr
source§impl From<&TextSubstr> for Box<TextSubstr>
impl From<&TextSubstr> for Box<TextSubstr>
source§fn from(s: &TextSubstr) -> Self
fn from(s: &TextSubstr) -> Self
source§impl From<&TextSubstr> for TextSubstring
impl From<&TextSubstr> for TextSubstring
source§fn from(s: &TextSubstr) -> Self
fn from(s: &TextSubstr) -> Self
source§impl From<&mut TextSubstr> for TextSubstring
impl From<&mut TextSubstr> for TextSubstring
source§fn from(s: &mut TextSubstr) -> Self
fn from(s: &mut TextSubstr) -> Self
source§impl From<Cow<'_, TextSubstr>> for Box<TextSubstr>
impl From<Cow<'_, TextSubstr>> for Box<TextSubstr>
source§fn from(cow: Cow<'_, TextSubstr>) -> Self
fn from(cow: Cow<'_, TextSubstr>) -> Self
source§impl From<TextSubstring> for Box<TextSubstr>
impl From<TextSubstring> for Box<TextSubstr>
source§fn from(s: TextSubstring) -> Self
fn from(s: TextSubstring) -> Self
source§impl Hash for TextSubstr
impl Hash for TextSubstr
source§impl Ord for TextSubstr
impl Ord for TextSubstr
source§impl<'a> PartialEq<&'a TextSubstr> for String
impl<'a> PartialEq<&'a TextSubstr> for String
source§fn eq(&self, other: &&'a TextSubstr) -> bool
fn eq(&self, other: &&'a TextSubstr) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a> PartialEq<&'a TextSubstr> for TextString
impl<'a> PartialEq<&'a TextSubstr> for TextString
source§fn eq(&self, other: &&'a TextSubstr) -> bool
fn eq(&self, other: &&'a TextSubstr) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a> PartialEq<&'a TextSubstr> for TextSubstring
impl<'a> PartialEq<&'a TextSubstr> for TextSubstring
source§fn eq(&self, other: &&'a TextSubstr) -> bool
fn eq(&self, other: &&'a TextSubstr) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a, 'b> PartialEq<&'b TextSubstr> for Cow<'a, TextStr>
impl<'a, 'b> PartialEq<&'b TextSubstr> for Cow<'a, TextStr>
source§fn eq(&self, other: &&TextSubstr) -> bool
fn eq(&self, other: &&TextSubstr) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a, 'b> PartialEq<&'b TextSubstr> for Cow<'a, TextSubstr>
impl<'a, 'b> PartialEq<&'b TextSubstr> for Cow<'a, TextSubstr>
source§fn eq(&self, other: &&TextSubstr) -> bool
fn eq(&self, other: &&TextSubstr) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a, 'b> PartialEq<&'b TextSubstr> for Cow<'a, str>
impl<'a, 'b> PartialEq<&'b TextSubstr> for Cow<'a, str>
source§fn eq(&self, other: &&TextSubstr) -> bool
fn eq(&self, other: &&TextSubstr) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a, 'b> PartialEq<Cow<'a, TextStr>> for &'b TextSubstr
impl<'a, 'b> PartialEq<Cow<'a, TextStr>> for &'b TextSubstr
source§impl<'a, 'b> PartialEq<Cow<'a, TextSubstr>> for &'b TextSubstr
impl<'a, 'b> PartialEq<Cow<'a, TextSubstr>> for &'b TextSubstr
source§impl<'a> PartialEq<Cow<'a, TextSubstr>> for TextSubstr
impl<'a> PartialEq<Cow<'a, TextSubstr>> for TextSubstr
source§impl<'a, 'b> PartialEq<Cow<'a, str>> for &'b TextSubstr
impl<'a, 'b> PartialEq<Cow<'a, str>> for &'b TextSubstr
source§impl<'a> PartialEq<Cow<'a, str>> for TextSubstr
impl<'a> PartialEq<Cow<'a, str>> for TextSubstr
source§impl<'a> PartialEq<String> for &'a TextSubstr
impl<'a> PartialEq<String> for &'a TextSubstr
source§impl PartialEq<String> for TextSubstr
impl PartialEq<String> for TextSubstr
source§impl<'a> PartialEq<TextString> for &'a TextSubstr
impl<'a> PartialEq<TextString> for &'a TextSubstr
source§fn eq(&self, other: &TextString) -> bool
fn eq(&self, other: &TextString) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialEq<TextString> for TextSubstr
impl PartialEq<TextString> for TextSubstr
source§fn eq(&self, other: &TextString) -> bool
fn eq(&self, other: &TextString) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a> PartialEq<TextSubstr> for Cow<'a, TextStr>
impl<'a> PartialEq<TextSubstr> for Cow<'a, TextStr>
source§fn eq(&self, other: &TextSubstr) -> bool
fn eq(&self, other: &TextSubstr) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a> PartialEq<TextSubstr> for Cow<'a, TextSubstr>
impl<'a> PartialEq<TextSubstr> for Cow<'a, TextSubstr>
source§fn eq(&self, other: &TextSubstr) -> bool
fn eq(&self, other: &TextSubstr) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a> PartialEq<TextSubstr> for Cow<'a, str>
impl<'a> PartialEq<TextSubstr> for Cow<'a, str>
source§fn eq(&self, other: &TextSubstr) -> bool
fn eq(&self, other: &TextSubstr) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialEq<TextSubstr> for String
impl PartialEq<TextSubstr> for String
source§fn eq(&self, other: &TextSubstr) -> bool
fn eq(&self, other: &TextSubstr) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialEq<TextSubstr> for TextString
impl PartialEq<TextSubstr> for TextString
source§fn eq(&self, other: &TextSubstr) -> bool
fn eq(&self, other: &TextSubstr) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialEq<TextSubstr> for TextSubstr
impl PartialEq<TextSubstr> for TextSubstr
source§fn eq(&self, other: &TextSubstr) -> bool
fn eq(&self, other: &TextSubstr) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialEq<TextSubstr> for TextSubstring
impl PartialEq<TextSubstr> for TextSubstring
source§fn eq(&self, other: &TextSubstr) -> bool
fn eq(&self, other: &TextSubstr) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialEq<TextSubstr> for str
impl PartialEq<TextSubstr> for str
source§fn eq(&self, other: &TextSubstr) -> bool
fn eq(&self, other: &TextSubstr) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a> PartialEq<TextSubstring> for &'a TextSubstr
impl<'a> PartialEq<TextSubstring> for &'a TextSubstr
source§fn eq(&self, other: &TextSubstring) -> bool
fn eq(&self, other: &TextSubstring) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialEq<TextSubstring> for TextSubstr
impl PartialEq<TextSubstring> for TextSubstr
source§fn eq(&self, other: &TextSubstring) -> bool
fn eq(&self, other: &TextSubstring) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialEq<str> for TextSubstr
impl PartialEq<str> for TextSubstr
source§impl PartialOrd<TextSubstr> for TextSubstr
impl PartialOrd<TextSubstr> for TextSubstr
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl ToOwned for TextSubstr
impl ToOwned for TextSubstr
§type Owned = TextSubstring
type Owned = TextSubstring
source§fn to_owned(&self) -> Self::Owned
fn to_owned(&self) -> Self::Owned
1.63.0 · source§fn clone_into(&self, target: &mut Self::Owned)
fn clone_into(&self, target: &mut Self::Owned)
source§impl ToSocketAddrs for TextSubstr
impl ToSocketAddrs for TextSubstr
§type Iter = IntoIter<SocketAddr, Global>
type Iter = IntoIter<SocketAddr, Global>
source§fn to_socket_addrs(&self) -> Result<Self::Iter>
fn to_socket_addrs(&self) -> Result<Self::Iter>
SocketAddr
s. Read more