pub struct Utf8Chunk<'a> { /* private fields */ }
🔬This is a nightly-only experimental API. (
utf8_chunks
#99543)Expand description
Utf8Chunks
迭代器返回的项。
在解码 UTF-8 字符串时,Utf8Chunk
存储一个 u8
序列,直到第一个断字符。
Examples
#![feature(utf8_chunks)]
use std::str::Utf8Chunks;
// 无效的 UTF-8 字符串
let bytes = b"foo\xF1\x80bar";
// 解码第一个 `Utf8Chunk`
let chunk = Utf8Chunks::new(bytes).next().unwrap();
// 前三个字符有效 UTF-8
assert_eq!("foo", chunk.valid());
// 第四个字符损坏了
assert_eq!(b"\xF1\x80", chunk.invalid());
RunImplementations§
Trait Implementations§
impl<'a> Eq for Utf8Chunk<'a>
impl<'a> StructuralEq for Utf8Chunk<'a>
impl<'a> StructuralPartialEq for Utf8Chunk<'a>
Auto Trait Implementations§
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> 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
从拥有的值中借用。 Read more