Struct basic_text::TextString [−][src]
#[repr(transparent)]pub struct TextString(_);
Expand description
A Basic Text encoded, growable string.
Implementations
impl TextString
[src]
impl TextString
[src]#[must_use]pub fn with_capacity(capacity: usize) -> Self
[src]
#[must_use]pub fn with_capacity(capacity: usize) -> Self
[src]Creates a new empty TextString
with a particular capacity.
pub fn from_text_vec(vec: Vec<u8>) -> Result<Self, FromTextError>
[src]
pub fn from_text_vec(vec: Vec<u8>) -> Result<Self, FromTextError>
[src]Converts a vector of bytes to a TextString
.
#[must_use]pub fn from_text_bytes_lossy(v: &[u8]) -> Cow<'_, TextStr>
[src]
#[must_use]pub fn from_text_bytes_lossy(v: &[u8]) -> Cow<'_, TextStr>
[src]Converts a slice of bytes to Basic Text, including invalid characters.
#[must_use]pub fn from_text_lossy(v: &str) -> Cow<'_, TextStr>
[src]
#[must_use]pub fn from_text_lossy(v: &str) -> Cow<'_, TextStr>
[src]Converts a string to Basic Text, including invalid characters.
#[must_use]pub unsafe fn from_text_vec_unchecked(vec: Vec<u8>) -> Self
[src]
#[must_use]pub unsafe fn from_text_vec_unchecked(vec: Vec<u8>) -> Self
[src]Converts a vector of bytes to a TextString
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 &TextStr
s
are valid Basic Text.
#[must_use]pub const unsafe fn from_text_unchecked(s: String) -> Self
[src]
#[must_use]pub const unsafe fn from_text_unchecked(s: String) -> Self
[src]Converts a String
to a TextString
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 &TextStr
s
are valid Basic Text.
#[must_use]pub fn into_bytes(self) -> Vec<u8>
[src]
#[must_use]pub fn into_bytes(self) -> Vec<u8>
[src]Converts a String into a byte vector.
#[must_use]pub fn as_utf8(&self) -> &str
[src]
#[must_use]pub fn as_utf8(&self) -> &str
[src]Extracts a UTF-8 string slice containing the entire TextString
.
#[must_use]pub fn as_str(&self) -> &TextStr
[src]
#[must_use]pub fn as_str(&self) -> &TextStr
[src]Extracts a Basic Text string slice containing the entire TextString
.
#[must_use]pub fn as_mut_utf8(&mut self) -> &mut str
[src]
#[must_use]pub fn as_mut_utf8(&mut self) -> &mut str
[src]Converts a TextString
into a mutable UTF-8 string slice.
#[must_use]pub fn as_mut_str(&mut self) -> &mut TextStr
[src]
#[must_use]pub fn as_mut_str(&mut self) -> &mut TextStr
[src]Converts a TextString
into a mutable Basic Text string slice.
pub fn push_str(&mut self, s: &TextStr)
[src]
pub fn push_str(&mut self, s: &TextStr)
[src]Appends a given string slice onto the end of this TextString
.
But wait, NFC isn’t closed under concatenation! This is true, but Basic Text has additional restrictions, including that strings start with non-combining codepoints, so it is closed under concatenation.
pub fn reserve(&mut self, additional: usize)
[src]
pub fn reserve(&mut self, additional: usize)
[src]Ensures that this TextString
’s capacity is at least additional
bytes larger than its length.
pub fn reserve_exact(&mut self, additional: usize)
[src]
pub fn reserve_exact(&mut self, additional: usize)
[src]Ensures that this TextString
’s capacity is additional
bytes larger
than its length.
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
[src]
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
[src]Tries to reserve capacity for at least additional
more elements to
be inserted in the given TextString
.
pub fn try_reserve_exact(
&mut self,
additional: usize
) -> Result<(), TryReserveError>
[src]
pub fn try_reserve_exact(
&mut self,
additional: usize
) -> Result<(), TryReserveError>
[src]Tries to reserves the minimum capacity for exactly additional
more
elements to be inserted in the given TextString
.
pub fn shrink_to_fit(&mut self)
[src]
pub fn shrink_to_fit(&mut self)
[src]Shrinks the capacity of this TextString
to match its length.
pub fn shrink_to(&mut self, min_capacity: usize)
[src]
pub fn shrink_to(&mut self, min_capacity: usize)
[src]Shrinks the capacity of this String
with a lower bound.
pub unsafe fn as_mut_vec(&mut self) -> &mut Vec<u8>
[src]
pub unsafe fn as_mut_vec(&mut self) -> &mut Vec<u8>
[src]Returns a mutable reference to the contents of this TextString
.
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, it may
cause memory unsafety issues with future users of the String, as the
rest of this crate assumes that TextString
s are valid Basic Text.
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
[src]Returns the length of this TextString
, in bytes, not char
s or
graphemes.
pub fn is_empty(&self) -> bool
[src]
pub fn is_empty(&self) -> bool
[src]Returns true
if this TextString
has a length of zero, and false
otherwise.
pub fn into_boxed_utf8(self) -> Box<str>
[src]
pub fn into_boxed_utf8(self) -> Box<str>
[src]Converts this TextString
into a Box<str>
.
pub fn into_boxed_str(self) -> Box<TextStr>
[src]
pub fn into_boxed_str(self) -> Box<TextStr>
[src]Converts this TextString
into a Box<TextStr>
.
Methods from Deref<Target = TextStr>
pub unsafe fn as_bytes_mut(&mut self) -> &mut [u8]
[src]
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 TextStr
is used.
Use of a TextStr
whose contents are not valid Basic Text is undefined
behavior.
pub fn as_mut_ptr(&mut self) -> *mut u8
[src]
pub fn as_mut_ptr(&mut self) -> *mut u8
[src]Converts a mutable text string slice to a raw pointer.
pub fn split_at(&self, mid: usize) -> (&Self, &Self)
[src]
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]
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 char_indices(&self) -> CharIndices<'_>
[src]
pub fn char_indices(&self) -> CharIndices<'_>
[src]Returns an iterator over the char
s of a text string slice, and their
positions.
pub fn lines(&self) -> Lines<'_>
[src]
pub fn lines(&self) -> Lines<'_>
[src]An iterator over the lines of a text string, as text string slices.
pub fn encode_utf16(&self) -> EncodeUtf16<'_>
[src]
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]
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]
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]
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]
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]
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]
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.
pub fn rmatches<'a, P>(&'a self, pat: P) -> RMatches<'a, P> where
P: Pattern<'a>,
<P as Pattern<'a>>::Searcher: ReverseSearcher<'a>,
[src]
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.
pub fn match_indices<'a, P>(&'a self, pat: P) -> MatchIndices<'a, P> where
P: Pattern<'a>,
[src]
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.
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]
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.
pub fn trim(&self) -> &Self
[src]
pub fn trim(&self) -> &Self
[src]Returns a text string slice with leading and trailing whitespace removed.
pub fn trim_start(&self) -> &Self
[src]
pub fn trim_start(&self) -> &Self
[src]Returns a text string slice with leading whitespace removed.
pub fn parse<F>(&self) -> Result<F, <F as FromStr>::Err> where
F: FromStr,
[src]
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]
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]
pub fn eq_ignore_ascii_case(&self, other: &Self) -> bool
[src]Checks that two text strings are an ASCII case-insensitive match.
Trait Implementations
impl Add<&'_ TextStr> for TextString
[src]
impl Add<&'_ TextStr> for TextString
[src]impl AddAssign<&'_ TextStr> for TextString
[src]
impl AddAssign<&'_ TextStr> for TextString
[src]fn add_assign(&mut self, other: &TextStr)
[src]
fn add_assign(&mut self, other: &TextStr)
[src]Performs the +=
operation. Read more
impl AsMut<TextStr> for TextString
[src]
impl AsMut<TextStr> for TextString
[src]impl Borrow<TextStr> for TextString
[src]
impl Borrow<TextStr> for TextString
[src]impl BorrowMut<TextStr> for TextString
[src]
impl BorrowMut<TextStr> for TextString
[src]fn borrow_mut(&mut self) -> &mut TextStr
[src]
fn borrow_mut(&mut self) -> &mut TextStr
[src]Mutably borrows from an owned value. Read more
impl Clone for TextString
[src]
impl Clone for TextString
[src]impl Debug for TextString
[src]
impl Debug for TextString
[src]impl Default for TextString
[src]
impl Default for TextString
[src]impl Deref for TextString
[src]
impl Deref for TextString
[src]impl DerefMut for TextString
[src]
impl DerefMut for TextString
[src]impl From<&'_ TextString> for TextString
[src]
impl From<&'_ TextString> for TextString
[src]impl From<&'_ mut TextStr> for TextString
[src]
impl From<&'_ mut TextStr> for TextString
[src]impl Hash for TextString
[src]
impl Hash for TextString
[src]impl<'a> PartialEq<&'a TextStr> for TextString
[src]
impl<'a> PartialEq<&'a TextStr> for TextString
[src]impl<'a> PartialEq<Cow<'a, TextStr>> for TextString
[src]
impl<'a> PartialEq<Cow<'a, TextStr>> for TextString
[src]impl<'a> PartialEq<String> for TextString
[src]
impl<'a> PartialEq<String> for TextString
[src]impl PartialEq<TextString> for TextString
[src]
impl PartialEq<TextString> for TextString
[src]fn eq(&self, other: &TextString) -> bool
[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
fn ne(&self, other: &TextString) -> bool
[src]
fn ne(&self, other: &TextString) -> bool
[src]This method tests for !=
.
impl<'a> PartialEq<str> for TextString
[src]
impl<'a> PartialEq<str> for TextString
[src]impl Eq for TextString
[src]
impl StructuralEq for TextString
[src]
impl StructuralPartialEq for TextString
[src]
Auto Trait Implementations
impl RefUnwindSafe for TextString
impl Send for TextString
impl Sync for TextString
impl Unpin for TextString
impl UnwindSafe for TextString
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[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