STL rework

- fixed lots of bugs
- overlay libraries work correctly and reliably
- the STL is an overlay library
- examples updated
This commit is contained in:
2023-06-17 21:12:23 +01:00
parent 5bb8a12fc2
commit aebbf51228
91 changed files with 1444 additions and 1395 deletions

View File

@@ -41,17 +41,13 @@ impl<'a, T> Substack<'a, T> {
}
/// Create a new frame on top of this substack
pub fn new_frame(&'a self, item: T) -> Stackframe<'a, T> {
Stackframe { item, prev: self, len: self.opt().map_or(1, |s| s.len) }
Stackframe { item, prev: self, len: self.opt().map_or(1, |s| s.len + 1) }
}
/// obtain the previous stackframe if one exists
/// TODO: this should return a [Substack]
pub fn pop(&'a self, count: usize) -> Option<&'a Stackframe<'a, T>> {
if let Self::Frame(p) = self {
if count == 0 {
Some(p)
} else {
p.prev.pop(count - 1)
}
if count == 0 { Some(p) } else { p.prev.pop(count - 1) }
} else {
None
}