allow exiting via flag
Some checks are pending
/ build (push) Waiting to run

This commit is contained in:
facile pop culture reference 2026-08-06 10:18:35 +03:00
parent 39d3dacf1f
commit cf67185ffd
2 changed files with 12 additions and 10 deletions

View file

@ -252,10 +252,11 @@ macro_rules! eval_xy (
#[cfg(feature = "exit")] pub use self::exit::*;
#[cfg(feature = "exit")] mod exit {
use crate::*;
use std::sync::{Arc, atomic::AtomicBool};
use std::sync::{Arc, atomic::{AtomicBool, Ordering::Relaxed}};
use crossterm::event::*;
#[derive(Clone)] pub struct Exit(Arc<AtomicBool>);
#[derive(Clone, Default, Debug)]
pub struct Exit(Arc<AtomicBool>);
impl Exit {
pub fn run <T> (run: impl FnOnce(Self)->Usually<T>) -> Usually<T> {
@ -269,6 +270,9 @@ macro_rules! eval_xy (
state: KeyEventState::NONE
}))
}
pub fn exit (&self) {
self.0.store(true, Relaxed)
}
}
impl AsRef<Arc<AtomicBool>> for Exit {