mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
wip: borrow checker battles
This commit is contained in:
parent
1d4db3c629
commit
7fbb40fad6
38 changed files with 778 additions and 708 deletions
|
|
@ -54,14 +54,13 @@ submod! {
|
|||
jack_ports
|
||||
render
|
||||
render_axis
|
||||
render_border
|
||||
render_buffer
|
||||
render_collect
|
||||
render_layered
|
||||
render_split
|
||||
render_tui
|
||||
render_tui_fill
|
||||
render_tui_theme
|
||||
render_tui_border
|
||||
time_base
|
||||
time_note
|
||||
time_tick
|
||||
|
|
@ -86,28 +85,28 @@ pub type Usually<T> = Result<T, Box<dyn Error>>;
|
|||
pub type Perhaps<T> = Result<Option<T>, Box<dyn Error>>;
|
||||
|
||||
/// A UI component.
|
||||
pub trait Component<T, U>: Render<T, U> + Handle + Sync {
|
||||
pub trait Component<'a, T, U>: Render<'a, T, U> + Handle + Sync {
|
||||
/// Perform type erasure for collecting heterogeneous components.
|
||||
fn boxed (self) -> Box<dyn Component<T, U>> where Self: Sized + 'static {
|
||||
fn boxed (self) -> Box<dyn Component<'a, T, U>> where Self: Sized + 'static {
|
||||
Box::new(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<C, T, U> Component<T, U> for C where C: Render<T, U> + Handle + Sync {}
|
||||
impl<'a, C, T, U> Component<'a, T, U> for C where C: Render<'a, T, U> + Handle + Sync {}
|
||||
|
||||
/// Marker trait for [Component]s that can [Exit]
|
||||
pub trait ExitableComponent<T, U>: Exit + Component<T, U> {
|
||||
pub trait ExitableComponent<'a, T, U>: Exit + Component<'a, T, U> {
|
||||
/// Perform type erasure for collecting heterogeneous components.
|
||||
fn boxed (self) -> Box<dyn ExitableComponent<T, U>> where Self: Sized + 'static {
|
||||
fn boxed (self) -> Box<dyn ExitableComponent<'a, T, U>> where Self: Sized + 'static {
|
||||
Box::new(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: Exit + Component<T, U>, T, U> ExitableComponent<T, U> for E {}
|
||||
impl<'a, E: Exit + Component<'a, T, U>, T, U> ExitableComponent<'a, T, U> for E {}
|
||||
|
||||
/// Run the main loop.
|
||||
pub fn run <R> (state: Arc<RwLock<R>>) -> Usually<Arc<RwLock<R>>>
|
||||
where R: for <'a> Render<TuiOutput<'a>, Rect> + Handle + Sized + 'static
|
||||
where R: for <'a> Render<'a, TuiOutput<'a>, Rect> + Handle + Sized + 'static
|
||||
{
|
||||
let exited = Arc::new(AtomicBool::new(false));
|
||||
let _input_thread = input_thread(&exited, &state);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue