forked from Orchid/orchid
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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user