and it once again compiles

This commit is contained in:
🪞👃🪞 2024-08-09 21:59:14 +03:00
parent 6dd4caeb42
commit 430c51e305
31 changed files with 466 additions and 694 deletions

View file

@ -2,7 +2,7 @@ pub use ratatui;
pub use crossterm;
pub use midly;
pub use clap;
pub use std::sync::{Arc, Mutex, RwLock};
pub use std::sync::{Arc, Mutex, RwLock, RwLockReadGuard, RwLockWriteGuard};
pub use std::collections::BTreeMap;
pub use crossterm::event::{Event, KeyEvent, KeyCode, KeyModifiers};
pub use ratatui::prelude::{Rect, Style, Color, Buffer};
@ -67,9 +67,18 @@ pub trait Component: Render + Handle + Sync {
}
}
/// Anything that implements `Render` + `Handle` can be used as a UI component.
impl<T: Render + Handle + Sync> Component for T {}
/// Marker trait for [Component]s that can [Exit]
pub trait ExitableComponent: Exit + Component {
/// Perform type erasure for collecting heterogeneous components.
fn boxed (self) -> Box<dyn ExitableComponent> where Self: Sized + 'static {
Box::new(self)
}
}
impl<T: Exit + Component> ExitableComponent for T {}
/// Run the main loop.
pub fn run <T> (state: Arc<RwLock<T>>) -> Usually<Arc<RwLock<T>>>
where T: Render + Handle + Send + Sync + Sized + 'static