lol/lol.rs
2024-03-22 22:47:41 -04:00

50 lines
877 B
Rust

// fuck notohhd donut imma impleme t sracks based on areayss
// https://femboy.beauty/o6T3a
#[derive(Clone, Debug, PartialEq)]
struct Stack<T> {
size: usize,
data: Box<[Option<T>]>,
}
impl<T: Copy> Stack<T> {
pub const MAX_SIZE: usize = 100;
fn new() -> Stack<T> {
Stack {
size: 0,
data: Box::new([None; Stack::<()>::MAX_SIZE]),
}
}
fn pop(&mut self) -> T {
let r = self.data[self.size - 1].unwrap();
self.size -= 1;
r
}
fn push(&mut self, e: T) {
self.data[self.size] = Some(e);
self.size += 1;
}
fn first(&self) -> T {
self.data[self.size - 1].unwrap()
}
fn size(&self) -> usize {
self.size
}
fn is_empty(&self) -> bool {
self.size == 0
}
}
fn main() {
println!(":)");
}