mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
refactor midi module
This commit is contained in:
parent
1723826cc2
commit
7f55c3bfc8
8 changed files with 333 additions and 330 deletions
|
|
@ -1,23 +1,25 @@
|
|||
use crate::*;
|
||||
|
||||
use std::sync::RwLock;
|
||||
|
||||
impl<E: Engine> Layout<E> for E {}
|
||||
|
||||
pub trait Layout<E: Engine> {
|
||||
/// Content `item` when `cond` is true.
|
||||
fn when <A: Content<E>> (cond: bool, item: A) -> When<E, A> {
|
||||
fn when <A> (cond: bool, item: A) -> When<E, A> where
|
||||
A: Content<E>
|
||||
{
|
||||
When(cond, item, Default::default())
|
||||
}
|
||||
/// Content `item` if `cond` is true, otherwise render `other`.
|
||||
fn either <A: Content<E>, B: Content<E>> (cond: bool, a: A, b: B)
|
||||
-> Either<E, A, B>
|
||||
fn either <A, B> (cond: bool, a: A, b: B) -> Either<E, A, B> where
|
||||
A: Content<E>,
|
||||
B: Content<E>,
|
||||
{
|
||||
Either(cond, a, b, Default::default())
|
||||
}
|
||||
/// Maps an [Option<T>] through a callback `F`
|
||||
fn opt <A, F: Fn(A)->R, R: Content<E>> (option: Option<A>, cb: F)
|
||||
-> Opt<E, A, F, R>
|
||||
fn opt <A, F, R> (option: Option<A>, cb: F) -> Opt<E, A, F, R> where
|
||||
F: Fn(A) -> R,
|
||||
R: Content<E>
|
||||
{
|
||||
Opt(option, cb, Default::default())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue