Struct pattern_3::Wtf8 [−][src]
pub struct Wtf8 { /* fields omitted */ }
A borrowed slice of well-formed WTF-8 data.
Similar to &str
, but can additionally contain surrogate code points
if they’re not in a surrogate pair.
Methods
impl Wtf8
[src]
impl Wtf8
pub fn from_str(value: &str) -> &Wtf8
[src]
pub fn from_str(value: &str) -> &Wtf8
Creates a WTF-8 slice from a UTF-8 &str
slice.
Since WTF-8 is a superset of UTF-8, this always succeeds.
pub unsafe fn from_bytes_unchecked(value: &[u8]) -> &Wtf8
[src]
pub unsafe fn from_bytes_unchecked(value: &[u8]) -> &Wtf8
Creates a WTF-8 slice from a WTF-8 byte slice.
Since the byte slice is not checked for valid WTF-8, this functions is marked unsafe.
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
Returns the length, in WTF-8 bytes.
pub fn is_empty(&self) -> bool
[src]
pub fn is_empty(&self) -> bool
pub fn ascii_byte_at(&self, position: usize) -> u8
[src]
pub fn ascii_byte_at(&self, position: usize) -> u8
Returns the code point at position
if it is in the ASCII range,
or `b'\xFF' otherwise.
Panics
Panics if position
is beyond the end of the string.
pub fn as_str(&self) -> Option<&str>
[src]
pub fn as_str(&self) -> Option<&str>
Tries to convert the string to UTF-8 and return a &str
slice.
Returns None
if the string contains surrogates.
This does not copy the data.
pub fn encode_wide(&self) -> EncodeWide
[src]
pub fn encode_wide(&self) -> EncodeWide
Converts the WTF-8 string to potentially ill-formed UTF-16 and return an iterator of 16-bit code units.
This is lossless:
calling Wtf8Buf::from_ill_formed_utf16
on the resulting code units
would always return the original WTF-8 string.
impl Wtf8
[src]
impl Wtf8
pub fn make_ascii_uppercase(&mut self)
[src]
pub fn make_ascii_uppercase(&mut self)
Trait Implementations
impl Debug for Wtf8
[src]
impl Debug for Wtf8
Format the slice with double quotes,
and surrogates as \u
followed by four hexadecimal digits.
Example: "a\u{D800}"
for a slice with code points [U+0061, U+D800]
fn fmt(&self, formatter: &mut Formatter) -> Result
[src]
fn fmt(&self, formatter: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Display for Wtf8
[src]
impl Display for Wtf8
fn fmt(&self, formatter: &mut Formatter) -> Result
[src]
fn fmt(&self, formatter: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl PartialEq for Wtf8
[src]
impl PartialEq for Wtf8
fn eq(&self, other: &Self) -> bool
[src]
fn eq(&self, other: &Self) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Self) -> bool
[src]
fn ne(&self, other: &Self) -> bool
This method tests for !=
.
impl Eq for Wtf8
[src]
impl Eq for Wtf8
impl PartialOrd for Wtf8
[src]
impl PartialOrd for Wtf8
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Self) -> bool
[src]
fn lt(&self, other: &Self) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Ord for Wtf8
[src]
impl Ord for Wtf8
fn cmp(&self, other: &Self) -> Ordering
[src]
fn cmp(&self, other: &Self) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl Index<Range<usize>> for Wtf8
[src]
impl Index<Range<usize>> for Wtf8
Return a slice of the given string for the byte range [begin
..end
).
Panics
Panics when begin
and end
do not point to code point boundaries,
or point beyond the end of the string.
type Output = Wtf8
The returned type after indexing.
fn index(&self, range: Range<usize>) -> &Wtf8
[src]
fn index(&self, range: Range<usize>) -> &Wtf8
Performs the indexing (container[index]
) operation.
impl Index<RangeFrom<usize>> for Wtf8
[src]
impl Index<RangeFrom<usize>> for Wtf8
Return a slice of the given string from byte begin
to its end.
Panics
Panics when begin
is not at a code point boundary,
or is beyond the end of the string.
type Output = Wtf8
The returned type after indexing.
fn index(&self, range: RangeFrom<usize>) -> &Wtf8
[src]
fn index(&self, range: RangeFrom<usize>) -> &Wtf8
Performs the indexing (container[index]
) operation.
impl Index<RangeTo<usize>> for Wtf8
[src]
impl Index<RangeTo<usize>> for Wtf8
Return a slice of the given string from its beginning to byte end
.
Panics
Panics when end
is not at a code point boundary,
or is beyond the end of the string.
type Output = Wtf8
The returned type after indexing.
fn index(&self, range: RangeTo<usize>) -> &Wtf8
[src]
fn index(&self, range: RangeTo<usize>) -> &Wtf8
Performs the indexing (container[index]
) operation.
impl Index<RangeFull> for Wtf8
[src]
impl Index<RangeFull> for Wtf8
type Output = Wtf8
The returned type after indexing.
fn index(&self, _range: RangeFull) -> &Wtf8
[src]
fn index(&self, _range: RangeFull) -> &Wtf8
Performs the indexing (container[index]
) operation.
impl Hash for Wtf8
[src]
impl Hash for Wtf8
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash<H: Hasher>(&self, state: &mut H)
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]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<'h, 'p> Pattern<&'h Wtf8> for &'p Wtf8
[src]
impl<'h, 'p> Pattern<&'h Wtf8> for &'p Wtf8
type Searcher = Wtf8Searcher<'p>
The searcher associated with this pattern.
type Consumer = Wtf8Checker<'p>
The checker associated with this pattern.
fn into_searcher(self) -> Self::Searcher
[src]
fn into_searcher(self) -> Self::Searcher
Produces a searcher for this pattern.
fn into_consumer(self) -> Self::Consumer
[src]
fn into_consumer(self) -> Self::Consumer
Produces a checker for this pattern.
impl<'h, 'p> Pattern<&'h Wtf8> for &'p str
[src]
impl<'h, 'p> Pattern<&'h Wtf8> for &'p str
type Searcher = SliceSearcher<'p, u8>
The searcher associated with this pattern.
type Consumer = SliceChecker<'p, u8>
The checker associated with this pattern.
fn into_searcher(self) -> Self::Searcher
[src]
fn into_searcher(self) -> Self::Searcher
Produces a searcher for this pattern.
fn into_consumer(self) -> Self::Consumer
[src]
fn into_consumer(self) -> Self::Consumer
Produces a checker for this pattern.
impl Hay for Wtf8
[src]
impl Hay for Wtf8
type Index = usize
The index type of the haystack. Typically a usize
. Read more
fn empty<'a>() -> &'a Self
[src]
fn empty<'a>() -> &'a Self
Creates an empty haystack.
fn start_index(&self) -> usize
[src]
fn start_index(&self) -> usize
Obtains the index to the start of the hay. Read more
fn end_index(&self) -> usize
[src]
fn end_index(&self) -> usize
Obtains the index to the end of the hay. Read more
unsafe fn slice_unchecked(&self, range: Range<usize>) -> &Self
[src]
unsafe fn slice_unchecked(&self, range: Range<usize>) -> &Self
Obtains a child hay by slicing self
. Read more
unsafe fn next_index(&self, index: usize) -> usize
[src]
unsafe fn next_index(&self, index: usize) -> usize
Returns the next immediate index in this haystack. Read more
unsafe fn prev_index(&self, index: usize) -> usize
[src]
unsafe fn prev_index(&self, index: usize) -> usize
Returns the previous immediate index in this haystack. Read more