1use crate::modal::Modal;
4
5#[cfg(test)]
6mod tests;
7
8#[derive(Debug, Default)]
10pub struct OverlayStack {
11 items: Vec<Modal>,
12}
13
14impl OverlayStack {
15 #[must_use]
16 pub const fn new() -> Self {
17 Self { items: Vec::new() }
18 }
19
20 pub fn push(&mut self, modal: Modal) {
21 self.items.push(modal);
22 }
23
24 pub fn pop(&mut self) -> Option<Modal> {
25 self.items.pop()
26 }
27
28 #[must_use]
29 pub fn top(&self) -> Option<&Modal> {
30 self.items.last()
31 }
32
33 #[must_use]
34 pub fn top_mut(&mut self) -> Option<&mut Modal> {
35 self.items.last_mut()
36 }
37
38 #[must_use]
39 pub fn is_empty(&self) -> bool {
40 self.items.is_empty()
41 }
42}