mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
this trait will NOT have a lifetime
This commit is contained in:
parent
38f69ddd50
commit
5e7b867aba
3 changed files with 67 additions and 64 deletions
|
|
@ -14,7 +14,7 @@ use std::{sync::Arc, marker::PhantomData};
|
|||
}
|
||||
$(
|
||||
impl<'a> Context<'a, $type> for $App {
|
||||
fn get (&'a $self, edn: &'a impl Atom<'a>) -> Option<$type> {
|
||||
fn get (&'a $self, edn: &'a impl Atom) -> Option<$type> {
|
||||
Some(match edn.to_ref() { $(Atom::Sym($sym) => $value,)* _ => return None })
|
||||
}
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ use std::{sync::Arc, marker::PhantomData};
|
|||
#[macro_export] macro_rules! provide_content {
|
||||
(|$self:ident:$State:ty|{ $($pat:pat => $expr:expr),* $(,)? }) => {
|
||||
impl<'a, E: Output> Context<'a, Box<dyn Render<E> + 'a>> for $State {
|
||||
fn get (&'a $self, edn: &'a impl Atom<'a>) -> Option<Box<dyn Render<E> + 'a>> {
|
||||
fn get (&'a $self, edn: &'a impl Atom) -> Option<Box<dyn Render<E> + 'a>> {
|
||||
Some(match edn.to_ref() {
|
||||
$(Atom::Sym($pat) => $expr),*,
|
||||
_ => return None
|
||||
|
|
@ -35,7 +35,7 @@ use std::{sync::Arc, marker::PhantomData};
|
|||
};
|
||||
($Output:ty: |$self:ident:$State:ty|{ $($pat:pat => $expr:expr),* $(,)? }) => {
|
||||
impl<'a> Context<'a, Box<dyn Render<$Output> + 'a>> for $State {
|
||||
fn get (&'a $self, edn: &'a impl Atom<'a>) -> Option<Box<dyn Render<$Output> + 'a>> {
|
||||
fn get (&'a $self, edn: &'a impl Atom) -> Option<Box<dyn Render<$Output> + 'a>> {
|
||||
Some(match edn.to_ref() {
|
||||
$(Atom::Sym($pat) => $expr),*,
|
||||
_ => return None
|
||||
|
|
@ -78,7 +78,7 @@ impl<'a, E: Output, T: ViewContext<'a, E> + std::fmt::Debug> EdnView<'a, E, T> {
|
|||
Err(error) => Self::Err(format!("{error} in {source}"))
|
||||
}
|
||||
}
|
||||
pub fn from_items (state: T, items: Vec<impl Atom<'a>>) -> Self {
|
||||
pub fn from_items (state: T, items: Vec<impl Atom>) -> Self {
|
||||
Self::Ok(state, Atom::Exp(items).to_arc())
|
||||
}
|
||||
}
|
||||
|
|
@ -112,7 +112,7 @@ pub trait ViewContext<'a, E: Output>:
|
|||
Context<'a, E::Unit> +
|
||||
Context<'a, Box<dyn Render<E> + 'a>>
|
||||
{
|
||||
fn get_bool (&'a self, item: &'a impl Atom<'a>) -> Option<bool> {
|
||||
fn get_bool (&'a self, item: &'a impl Atom) -> Option<bool> {
|
||||
Some(match &item {
|
||||
Sym(s) => match s.as_ref() {
|
||||
":false" | ":f" => false,
|
||||
|
|
@ -124,13 +124,13 @@ pub trait ViewContext<'a, E: Output>:
|
|||
_ => return Context::get(self, item)
|
||||
})
|
||||
}
|
||||
fn get_usize (&'a self, item: &'a impl Atom<'a>) -> Option<usize> {
|
||||
fn get_usize (&'a self, item: &'a impl Atom) -> Option<usize> {
|
||||
Some(match &item { Num(n) => *n, _ => return Context::get(self, item) })
|
||||
}
|
||||
fn get_unit (&'a self, item: &'a impl Atom<'a>) -> Option<E::Unit> {
|
||||
fn get_unit (&'a self, item: &'a impl Atom) -> Option<E::Unit> {
|
||||
Some(match &item { Num(n) => (*n as u16).into(), _ => return Context::get(self, item) })
|
||||
}
|
||||
fn get_content (&'a self, item: &'a impl Atom<'a>) -> Option<Box<dyn Render<E> + 'a>> where E: 'a {
|
||||
fn get_content (&'a self, item: &'a impl Atom) -> Option<Box<dyn Render<E> + 'a>> where E: 'a {
|
||||
Some(match item {
|
||||
Nil => Box::new(()),
|
||||
Exp(ref e) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue