use std::error;
pub type AppResult<T> = std::result::Result<T, Box<dyn error::Error>>;
#[derive(Debug)]
pub struct App {
pub running: bool,
pub counter: u8,
}
impl Default for App {
fn default() -> Self {
Self {
running: true,
counter: 0,
}
}
}
impl App {
pub fn new() -> Self {
Self::default()
}
pub fn tick(&self) {}
pub fn quit(&mut self) {
self.running = false;
}
pub fn increment_counter(&mut self) {
if let Some(res) = self.counter.checked_add(1) {
self.counter = res;
}
}
pub fn decrement_counter(&mut self) {
if let Some(res) = self.counter.checked_sub(1) {
self.counter = res;
}
}
}