pub struct Utf8Chunk<'a> {
valid: &'a str,
invalid: &'a [u8],
}
Expand description
An item returned by the Utf8Chunks
iterator.
A Utf8Chunk
stores a sequence of u8
up to the first broken character
when decoding a UTF-8 string.
§Examples
Fields§
§valid: &'a str
§invalid: &'a [u8]
Implementations§
Source§impl<'a> Utf8Chunk<'a>
impl<'a> Utf8Chunk<'a>
1.79.0 · Sourcepub fn valid(&self) -> &'a str
pub fn valid(&self) -> &'a str
Returns the next validated UTF-8 substring.
This substring can be empty at the start of the string or between broken UTF-8 characters.
1.79.0 · Sourcepub fn invalid(&self) -> &'a [u8]
pub fn invalid(&self) -> &'a [u8]
Returns the invalid sequence that caused a failure.
The returned slice will have a maximum length of 3 and starts after the
substring given by valid
. Decoding will resume after this sequence.
If empty, this is the last chunk in the string. If non-empty, an unexpected byte was encountered or the end of the input was reached unexpectedly.
Lossy decoding would replace this sequence with U+FFFD REPLACEMENT CHARACTER
.
Trait Implementations§
1.79.0 · Source§impl<'a> Eq for Utf8Chunk<'a>
impl<'a> Eq for Utf8Chunk<'a>
#[doc(hidden)] fn assert_receiver_is_total_eq(&self)
impl<'a> StructuralPartialEq for Utf8Chunk<'a>
Auto Trait Implementations§
impl<'a> Freeze for Utf8Chunk<'a>
impl<'a> RefUnwindSafe for Utf8Chunk<'a>
impl<'a> Send for Utf8Chunk<'a>
impl<'a> Sync for Utf8Chunk<'a>
impl<'a> Unpin for Utf8Chunk<'a>
impl<'a> UnsafeUnpin for Utf8Chunk<'a>
impl<'a> UnwindSafe for Utf8Chunk<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)] const IS_ZST: bool = _
#[doc(hidden)] const IS_ZST: bool = _
🔬This is a nightly-only experimental API. (
sized_type_properties
)Source§#[doc(hidden)] const LAYOUT: Layout = _
#[doc(hidden)] const LAYOUT: Layout = _
🔬This is a nightly-only experimental API. (
sized_type_properties
)Source§#[doc(hidden)] const MAX_SLICE_LEN: usize = _
#[doc(hidden)] const MAX_SLICE_LEN: usize = _
🔬This is a nightly-only experimental API. (
sized_type_properties
)The largest safe length for a
[Self]
. Read more