summaryrefslogtreecommitdiff
path: root/src/fixed_string/iter/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/fixed_string/iter/mod.rs')
-rw-r--r--src/fixed_string/iter/mod.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/fixed_string/iter/mod.rs b/src/fixed_string/iter/mod.rs
new file mode 100644
index 0000000..12de225
--- /dev/null
+++ b/src/fixed_string/iter/mod.rs
@@ -0,0 +1,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)
+ }
+}