Closed
Description
Feature gate: #![feature(utf8_chunks)]
This is a tracking issue for an improved API for str::from_utf8
.
Public API
// core::str
pub struct Utf8Chunks<'a> { ... }
impl<'a> Utf8Chunks<'a> {
pub fn new(bytes: &'a [u8]) -> Self;
}
impl<'a> Iterator for Utf8Chunks<'a> {
type Item = Utf8Chunk<'a>;
}
impl<'a> Clone for Utf8Chunks<'a>;
impl<'a> Debug for Utf8Chunks<'a>;
impl<'a> FusedIterator for Utf8Chunks<'a>;
pub struct Utf8Chunk<'a> { ... }
impl<'a> Utf8Chunk<'a> {
pub fn valid(&self) -> &'a str;
pub fn invalid(&self) -> &'a [u8];
}
impl<'a> Clone for Utf8Chunk<'a>;
impl<'a> Debug for Utf8Chunk<'a>;
impl<'a> PartialEq for Utf8Chunk<'a>;
impl<'a> Eq for Utf8Chunk<'a>;
Steps / History
- Proposal: Expose
Utf8LossyChunksIter
libs-team#54 - Implementation: Expose
Utf8Lossy
asUtf8Chunks
#99544 - Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
- Should the constructor be
Utf8Chunks::new
or<[u8]>::utf8_chunks
? - Should
Utf8Chunks::debug
or a similar method be exposed?