pub struct Runes<'g> { /* private fields */ }Expand description
Represents a slice of bytes which can be automatically parsed into a sequence of Rune(s)
Β§Examples
use utf8_rune::Runes;
let parts = Runes::new("π©π»βπππΏπ§π½βππ¨βππΆοΈπΉππ₯β€οΈβπ₯β€οΈβπ©Ή");
assert_eq!(
parts
.to_vec()
.iter()
.map(|rune| rune.to_string())
.collect::<Vec<String>>(),
vec![
"π©π»βπ",
"ππΏ",
"π§π½βπ",
"π¨βπ",
"πΆοΈ",
"πΉ",
"π",
"π₯",
"β€οΈβπ₯",
"β€οΈβπ©Ή",
]
);use utf8_rune::Runes;
let runes = Runes::new("πππ»ππΌππ½ππΎππΏ");
assert_eq!(runes.rune_indexes(), vec![
(0, 4),
(4, 8),
(12, 8),
(20, 8),
(28, 8),
(36, 8),
]);
assert_eq!(runes.len(), 6);
assert_eq!(runes[0], "π");
assert_eq!(runes[1], "ππ»");
assert_eq!(runes[2], "ππΌ");
assert_eq!(runes[3], "ππ½");
assert_eq!(runes[4], "ππΎ");
assert_eq!(runes[5], "ππΏ");ImplementationsΒ§
SourceΒ§impl<'g> Runes<'g>
impl<'g> Runes<'g>
pub fn new<T: Display>(input: T) -> Runes<'g>
pub fn allocate<T: Display>(input: T) -> Result<Runes<'g>>
pub fn empty() -> Result<Runes<'g>>
pub fn as_str(&self) -> &'g str
pub fn as_bytes(&self) -> &'g [u8] β
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
pub fn as_debug(&self, indent: Option<usize>) -> String
pub fn indexes(&self) -> Vec<usize>
pub fn rune_indexes(&self) -> Vec<(usize, usize)>
pub fn get(&self, index: usize) -> Option<Rune>
pub fn to_vec(&self) -> Vec<Rune>
Trait ImplementationsΒ§
Auto Trait ImplementationsΒ§
impl<'g> Freeze for Runes<'g>
impl<'g> RefUnwindSafe for Runes<'g>
impl<'g> !Send for Runes<'g>
impl<'g> !Sync for Runes<'g>
impl<'g> Unpin for Runes<'g>
impl<'g> UnwindSafe for Runes<'g>
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