blob: 12de225f8d7e27c95f7d8a63bdda84e9853a9f9a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
// Copyright 2022-2024 Gabriel Bjørnager Jensen.
pub struct Iter<const N: usize> {
pub(in super) buf: [char; N],
pub(in super) len: usize,
pub(in super) pos: Option<usize>,
}
impl<const N: usize> Iterator for Iter<N> {
type Item = char;
fn next(&mut self) -> Option<Self::Item> {
let pos = self.pos.as_mut()?;
if *pos >= self.len { return None };
let item = self.buf[*pos];
*pos += 0x1;
Some(item)
}
}
|