pub trait EncodedStr: Sealed {
type CHAR;
type SLICE: ?Sized;
const ELEMENT_LEN_BYTE: usize = _;
const CHAR: usize = Self::ELEMENT_LEN_BYTE;
const UTF8: bool = false;
// Required methods
fn is_ascii(&self) -> bool;
fn as_bytes(&self) -> &[u8] ⓘ;
unsafe fn get_unchecked<I: SliceIndex<Self::SLICE, Output = Self::SLICE>>(
&self,
i: I,
) -> &Self;
unsafe fn get_unchecked_from(&self, range: RangeFrom<usize>) -> &Self;
fn char_index_strs(&self) -> impl Iterator<Item = (usize, char, &Self)>;
fn char_len_next_strs(&self) -> impl Iterator<Item = (char, usize, &Self)>;
// Provided method
fn chars_count(&self) -> usize { ... }
}
Expand description
§Performance
Although multiple encodings are supported, UTF-8 (str
) is most optimized.
TODO: Extended ASCII code pages TODO: Index/SliceIndex
Provided Associated Constants§
const ELEMENT_LEN_BYTE: usize = _
const CHAR: usize = Self::ELEMENT_LEN_BYTE
const UTF8: bool = false
Required Associated Types§
Required Methods§
fn is_ascii(&self) -> bool
fn as_bytes(&self) -> &[u8] ⓘ
unsafe fn get_unchecked<I: SliceIndex<Self::SLICE, Output = Self::SLICE>>( &self, i: I, ) -> &Self
unsafe fn get_unchecked_from(&self, range: RangeFrom<usize>) -> &Self
fn char_index_strs(&self) -> impl Iterator<Item = (usize, char, &Self)>
fn char_len_next_strs(&self) -> impl Iterator<Item = (char, usize, &Self)>
Provided Methods§
fn chars_count(&self) -> usize
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl EncodedStr for str
impl EncodedStr for str
const UTF8: bool = true
type CHAR = u8
type SLICE = str
fn is_ascii(&self) -> bool
fn as_bytes(&self) -> &[u8] ⓘ
unsafe fn get_unchecked<I: SliceIndex<Self::SLICE, Output = Self::SLICE>>( &self, i: I, ) -> &Self
unsafe fn get_unchecked_from(&self, range: RangeFrom<usize>) -> &Self
fn char_index_strs(&self) -> impl Iterator<Item = (usize, char, &Self)>
fn char_len_next_strs(&self) -> impl Iterator<Item = (char, usize, &Self)>
fn chars_count(&self) -> usize
Source§impl EncodedStr for U16Str
Available on crate feature encoding
only.
impl EncodedStr for U16Str
Available on crate feature
encoding
only.type CHAR = u16
type SLICE = [u16]
fn is_ascii(&self) -> bool
fn as_bytes(&self) -> &[u8] ⓘ
unsafe fn get_unchecked<I: SliceIndex<Self::SLICE, Output = Self::SLICE>>( &self, i: I, ) -> &Self
unsafe fn get_unchecked_from(&self, range: RangeFrom<usize>) -> &Self
fn char_index_strs(&self) -> impl Iterator<Item = (usize, char, &Self)>
fn char_len_next_strs(&self) -> impl Iterator<Item = (char, usize, &Self)>
Source§impl EncodedStr for U32Str
Available on crate feature encoding
only.
impl EncodedStr for U32Str
Available on crate feature
encoding
only.