diff --git a/dsl/src/dsl_provide.rs b/dsl/src/dsl_provide.rs index c2f411f..66e18d8 100644 --- a/dsl/src/dsl_provide.rs +++ b/dsl/src/dsl_provide.rs @@ -1,114 +1,70 @@ use crate::*; -pub trait Dsl { - fn take <'source> (&self, words: &mut TokenIter<'source>) -> Perhaps; - fn take_or_fail <'source, E: Into>, F: Fn()->E> ( +pub trait Receive { + fn receive <'source> (&self, words: &mut TokenIter<'source>) -> Perhaps; + fn receive_or_fail <'source, E: Into>, F: Fn()->E> ( &self, words: &mut TokenIter<'source>, error: F ) -> Usually { - if let Some(value) = Dsl::::take(self, words)? { + if let Some(value) = Receive::::receive(self, words)? { Ok(value) } else { - Result::Err(format!("{}: {:?}", error().into(), words.peek().map(|x|x.value)).into()) + Result::Err(format!("receive: {}: {:?}", error().into(), words.peek().map(|x|x.value)).into()) } } } -impl, State> Dsl for State { - fn take <'source> (&self, words: &mut TokenIter<'source>) -> Perhaps { - Namespace::take_from(self, words) - } -} - -pub trait Namespace: Sized { - fn take_from <'source> (state: &State, words: &mut TokenIter<'source>) +pub trait Provide<'n, State>: Sized + 'n { + fn provide <'source> (state: &State, words: &mut TokenIter<'source>) -> Perhaps; - fn take_from_or_fail <'source, E: Into>, F: Fn()->E> ( + fn provide_or_fail <'source, E: Into>, F: Fn()->E> ( state: &State, words: &mut TokenIter<'source>, error: F ) -> Usually { - if let Some(value) = Namespace::::take_from(state, words)? { + if let Some(value) = Provide::::provide(state, words)? { Ok(value) } else { - Result::Err(format!("{}: {:?}", error().into(), words.peek().map(|x|x.value)).into()) + Result::Err(format!("provide: {}: {:?}", error().into(), words.peek().map(|x|x.value)).into()) } } } -//impl, T> Namespace for T { - //fn take_from <'state, 'source: 'state> (state: &'state State, token: &mut TokenIter<'source>) - //-> Perhaps - //{ - //Dsl::take(state, token) - //} -//} - -/// Implement the [Dsl] trait, which boils down to +/// Implement the [Receive] trait, which boils down to /// specifying two types and providing an expression. #[macro_export] macro_rules! from_dsl { (@a: $T:ty: |$state:ident, $words:ident|$expr:expr) => { - impl, A> Namespace for $T { - fn take_from <'source> ( - $state: &State, - $words: &mut TokenIter<'source>, - ) -> Perhaps<$T> { + impl<'n, State, A: Provide<'n, State>> Provide<'n, State> for $T { + fn provide <'source> ($state: &State, $words: &mut TokenIter<'source>) -> Perhaps<$T> { $expr } } }; (@ab: $T:ty: |$state:ident, $words:ident|$expr:expr) => { - impl + Dsl, A, B> Namespace for $T { - fn take_from <'source> ( - $state: &State, - $words: &mut TokenIter<'source>, - ) -> Perhaps<$T> { + impl<'n, State, A: Provide<'n, State>, B: Provide<'n, State>> Provide<'n, State> for $T { + fn provide <'source> ($state: &State, $words: &mut TokenIter<'source>) -> Perhaps<$T> { $expr } } }; ($T:ty: |$state:ident:$S:ty, $words:ident|$expr:expr) => { - impl Namespace<$S> for $T { - fn take_from <'source> ( - $state: &$S, - $words: &mut TokenIter<'source>, - ) -> Perhaps<$T> { + impl<'n> Provide<'n, $S> for $T { + fn provide <'source> ($state: &$S, $words: &mut TokenIter<'source>) -> Perhaps<$T> { $expr } } }; } -///// Maps a sequencer of EDN tokens to parameters of supported types -///// for a given context. -//pub trait Dsl: Sized { - //fn take <'state, 'source> (&'state self, _: &mut TokenIter<'source>) -> Perhaps { - //unimplemented!() - //} - //fn take_or_fail <'state, 'source> ( - //&'state self, - //token: &mut TokenIter<'source>, - //error: impl Into> - //) -> Usually { - //if let Some(value) = Dsl::::take(self, token)? { - //Ok(value) - //} else { - //Result::Err(error.into()) - //} +// auto impl graveyard: + +//impl<'n, State: Receive, Type: 'n> Provide<'n, State> for Type { + //fn provide <'source> (state: &State, words: &mut TokenIter<'source>) + //-> Perhaps + //{ + //state.take(words) //} //} -//impl, U> Dsl for &T { - //fn take <'state, 'source> (&'state self, iter: &mut TokenIter<'source>) -> Perhaps { - //(*self).take(iter) +//impl<'n, Type: Provide<'n, State>, State> Receive for State { + //fn take <'source> (&self, words: &mut TokenIter<'source>) -> Perhaps { + //Type::provide(self, words) //} //} - -//impl, U> Dsl for Option { - //fn take <'state, 'source> (&'state self, iter: &mut TokenIter<'source>) -> Perhaps { - //Ok(self.as_ref().map(|s|s.take(iter)).transpose()?.flatten()) - //} -//} - -//impl<'state, X, Y> Dsl for Y where Y: Dsl<'state, X> { -//} - -//impl> Dsl for T { -//} diff --git a/input/src/input_dsl.rs b/input/src/input_dsl.rs index 046417a..5df10cb 100644 --- a/input/src/input_dsl.rs +++ b/input/src/input_dsl.rs @@ -5,15 +5,13 @@ use std::marker::PhantomData; pub trait DslInput: Input { fn matches_dsl (&self, token: &str) -> bool; } /// A pre-configured mapping of input events to commands. -pub trait KeyMap<'source, S, C: Namespace + Command, I: DslInput> { +pub trait KeyMap<'k, S, C: Provide<'k, S> + Command, I: DslInput> { /// Try to find a command that matches the current input event. fn keybind_resolve (&self, state: &S, input: &I) -> Perhaps; } /// A [SourceIter] can be a [KeyMap]. -impl<'source, S, C: Namespace + Command, I: DslInput> -KeyMap<'source, S, C, I> -for SourceIter<'source> { +impl<'k, S, C: Provide<'k, S> + Command, I: DslInput> KeyMap<'k, S, C, I> for SourceIter<'k> { fn keybind_resolve (&self, state: &S, input: &I) -> Perhaps { let mut iter = self.clone(); while let Some((token, rest)) = iter.next() { @@ -24,7 +22,7 @@ for SourceIter<'source> { match exp_iter.next() { Some(Token { value: Value::Sym(binding), .. }) => { if input.matches_dsl(binding) { - if let Some(command) = Namespace::take_from(state, &mut exp_iter)? { + if let Some(command) = Provide::provide(state, &mut exp_iter)? { return Ok(Some(command)) } } @@ -40,9 +38,7 @@ for SourceIter<'source> { } /// A [TokenIter] can be a [KeyMap]. -impl<'source, S, C: Namespace + Command, I: DslInput> -KeyMap<'source, S, C, I> -for TokenIter<'source> { +impl<'k, S, C: Provide<'k, S> + Command, I: DslInput> KeyMap<'k, S, C, I> for TokenIter<'k> { fn keybind_resolve (&self, state: &S, input: &I) -> Perhaps { let mut iter = self.clone(); while let Some(next) = iter.next() { @@ -52,7 +48,7 @@ for TokenIter<'source> { match e.next() { Some(Token { value: Value::Sym(binding), .. }) => { if input.matches_dsl(binding) { - if let Some(command) = Namespace::take_from(state, &mut e)? { + if let Some(command) = Provide::provide(state, &mut e)? { return Ok(Some(command)) } } @@ -67,38 +63,33 @@ for TokenIter<'source> { } } -pub type InputCondition<'source, S> = - BoxUsually + Send + Sync + 'source>; +pub type InputCondition<'k, S> = BoxUsually + Send + Sync + 'k>; /// A collection of pre-configured mappings of input events to commands, /// which may be made available subject to given conditions. -pub struct InputMap<'source, +pub struct InputMap<'k, S, - C: Command + Namespace, + C: Command + Provide<'k, S>, I: DslInput, - M: KeyMap<'source, S, C, I> + M: KeyMap<'k, S, C, I> > { - __: PhantomData<&'source (S, C, I)>, - pub layers: Vec<(InputCondition<'source, S>, M)>, + __: PhantomData<&'k (S, C, I)>, + pub layers: Vec<(InputCondition<'k, S>, M)>, } -impl<'source, +impl<'k, S, - C: Command + Namespace, + C: Command + Provide<'k, S>, I: DslInput, - M: KeyMap<'source, S, C, I> -> Default for InputMap<'source, S, C, I, M>{ + M: KeyMap<'k, S, C, I> +> Default for InputMap<'k, S, C, I, M>{ fn default () -> Self { Self { __: PhantomData, layers: vec![] } } } -impl<'source, - S, - C: Command + Namespace, - I: DslInput, - M: KeyMap<'source, S, C, I> -> InputMap<'source, S, C, I, M> { +impl<'k, S, C: Command + Provide<'k, S>, I: DslInput, M: KeyMap<'k, S, C, I>> +InputMap<'k, S, C, I, M> { pub fn new (keymap: M) -> Self { Self::default().layer(keymap) } @@ -110,34 +101,30 @@ impl<'source, self.add_layer_if(Box::new(|_|Ok(true)), keymap); self } - pub fn layer_if (mut self, condition: InputCondition<'source, S>, keymap: M) -> Self { + pub fn layer_if (mut self, condition: InputCondition<'k, S>, keymap: M) -> Self { self.add_layer_if(condition, keymap); self } - pub fn add_layer_if (&mut self, condition: InputCondition<'source, S>, keymap: M) -> &mut Self { + pub fn add_layer_if (&mut self, condition: InputCondition<'k, S>, keymap: M) -> &mut Self { self.layers.push((Box::new(condition), keymap)); self } } -impl<'source, - S, - C: Command + Namespace, - I: DslInput, - M: KeyMap<'source, S, C, I> -> std::fmt::Debug for InputMap<'source, S, C, I, M> { +impl<'k, S, C: Command + Provide<'k, S>, I: DslInput, M: KeyMap<'k, S, C, I>> +std::fmt::Debug for InputMap<'k, S, C, I, M> { fn fmt (&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { write!(f, "[InputMap: {} layer(s)]", self.layers.len()) } } /// An [InputMap] can be a [KeyMap]. -impl<'source, +impl<'k, S, - C: Command + Namespace, + C: Command + Provide<'k, S>, I: DslInput, - M: KeyMap<'source, S, C, I> -> KeyMap<'source, S, C, I> for InputMap<'source, S, C, I, M> { + M: KeyMap<'k, S, C, I> +> KeyMap<'k, S, C, I> for InputMap<'k, S, C, I, M> { fn keybind_resolve (&self, state: &S, input: &I) -> Perhaps { for (condition, keymap) in self.layers.iter() { if !condition(state)? { diff --git a/output/src/ops/align.rs b/output/src/ops/align.rs index 0809a10..ee168ea 100644 --- a/output/src/ops/align.rs +++ b/output/src/ops/align.rs @@ -36,33 +36,36 @@ pub enum Alignment { #[default] Center, X, Y, NW, N, NE, E, SE, S, SW, W } pub struct Align(Alignment, A); #[cfg(feature = "dsl")] -from_dsl!(@a: Align: |state, iter|if let Some(Token { value: Value::Key(key), .. }) = iter.peek() { - match key { - "align/c"|"align/x"|"align/y"| - "align/n"|"align/s"|"align/e"|"align/w"| - "align/nw"|"align/sw"|"align/ne"|"align/se" => { - let _ = iter.next().unwrap(); - let content = state.take_or_fail(&mut iter.clone(), ||"expected content")?; - return Ok(Some(match key { - "align/c" => Self::c(content), - "align/x" => Self::x(content), - "align/y" => Self::y(content), - "align/n" => Self::n(content), - "align/s" => Self::s(content), - "align/e" => Self::e(content), - "align/w" => Self::w(content), - "align/nw" => Self::nw(content), - "align/ne" => Self::ne(content), - "align/sw" => Self::sw(content), - "align/se" => Self::se(content), - _ => unreachable!() - })) - }, - _ => return Ok(None) +impl<'n, State: Receive, A: 'n> Provide<'n, State> for Align { + fn provide <'source> (state: &State, words: &mut TokenIter<'source>) -> Perhaps { + if let Some(Token { value: Value::Key(key), .. }) = words.peek() { + match key { + "align/c"|"align/x"|"align/y"| + "align/n"|"align/s"|"align/e"|"align/w"| + "align/nw"|"align/sw"|"align/ne"|"align/se" => { + let _ = words.next().unwrap(); + let content = state.receive_or_fail(&mut words.clone(), ||"expected content")?; + return Ok(Some(match key { + "align/c" => Self::c(content), + "align/x" => Self::x(content), + "align/y" => Self::y(content), + "align/n" => Self::n(content), + "align/s" => Self::s(content), + "align/e" => Self::e(content), + "align/w" => Self::w(content), + "align/nw" => Self::nw(content), + "align/ne" => Self::ne(content), + "align/sw" => Self::sw(content), + "align/se" => Self::se(content), + _ => unreachable!() + })) + }, + _ => {} + } + } + Ok(None) } -} else { - Ok(None) -}); +} impl Align { #[inline] pub const fn c (a: A) -> Self { Self(Alignment::Center, a) } diff --git a/output/src/ops/bsp.rs b/output/src/ops/bsp.rs index 41fd5e6..cb38197 100644 --- a/output/src/ops/bsp.rs +++ b/output/src/ops/bsp.rs @@ -21,24 +21,28 @@ impl, B: Content> Content for Bsp { } } #[cfg(feature = "dsl")] -impl + Dsl + std::fmt::Debug, A, B> Namespace for Bsp { - fn take_from <'source> (state: &State, words: &mut TokenIter<'source>) -> Perhaps { +impl<'n, State: Receive + Receive, A: 'n, B: 'n> Provide<'n, State> for Bsp { + fn provide <'source> (state: &State, words: &mut TokenIter<'source>) -> Perhaps { Ok(if let Some(Token { value: Value::Key("bsp/n"|"bsp/s"|"bsp/e"|"bsp/w"|"bsp/a"|"bsp/b"), .. }) = words.peek() { - let base = words.clone(); - let a: A = state.take_or_fail(words, ||"expected content 1")?; - let b: B = state.take_or_fail(words, ||"expected content 2")?; - return Ok(Some(match words.next() { - Some(Token { value: Value::Key("bsp/n"), .. }) => Self::n(a, b), - Some(Token { value: Value::Key("bsp/s"), .. }) => Self::s(a, b), - Some(Token { value: Value::Key("bsp/e"), .. }) => Self::e(a, b), - Some(Token { value: Value::Key("bsp/w"), .. }) => Self::w(a, b), - Some(Token { value: Value::Key("bsp/a"), .. }) => Self::a(a, b), - Some(Token { value: Value::Key("bsp/b"), .. }) => Self::b(a, b), - _ => unreachable!(), - })) + if let Value::Key(key) = words.next().unwrap().value() { + let base = words.clone(); + let a: A = state.receive_or_fail(words, ||"bsp: expected content 1")?; + let b: B = state.receive_or_fail(words, ||"bsp: expected content 2")?; + return Ok(Some(match key { + "bsp/n" => Self::n(a, b), + "bsp/s" => Self::s(a, b), + "bsp/e" => Self::e(a, b), + "bsp/w" => Self::w(a, b), + "bsp/a" => Self::a(a, b), + "bsp/b" => Self::b(a, b), + _ => unreachable!(), + })) + } else { + unreachable!() + } } else { None }) diff --git a/output/src/ops/either.rs b/output/src/ops/either.rs index b8e6ef9..d3813c1 100644 --- a/output/src/ops/either.rs +++ b/output/src/ops/either.rs @@ -9,18 +9,15 @@ impl Either { } } #[cfg(feature = "dsl")] -impl + Dsl + Dsl> Namespace for Either { - fn take_from <'source> ( - state: &T, - token: &mut TokenIter<'source> - ) -> Perhaps { +impl<'n, State: Receive + Receive + Receive, A: 'n, B: 'n> Provide<'n, State> for Either { + fn provide <'source> (state: &State, token: &mut TokenIter<'source>) -> Perhaps { if let Some(Token { value: Value::Key("either"), .. }) = token.peek() { let base = token.clone(); let _ = token.next().unwrap(); return Ok(Some(Self( - state.take_or_fail(token, ||"either: no condition")?, - state.take_or_fail(token, ||"either: no content 1")?, - state.take_or_fail(token, ||"either: no content 2")?, + state.receive_or_fail(token, ||"either: no condition")?, + state.receive_or_fail(token, ||"either: no content 1")?, + state.receive_or_fail(token, ||"either: no content 2")?, ))) } Ok(None) diff --git a/output/src/ops/transform.rs b/output/src/ops/transform.rs index 9719c9a..2715bde 100644 --- a/output/src/ops/transform.rs +++ b/output/src/ops/transform.rs @@ -33,19 +33,19 @@ macro_rules! transform_xy { #[inline] pub const fn xy (item: A) -> Self { Self::XY(item) } } #[cfg(feature = "dsl")] - impl> Namespace for $Enum { - fn take_from <'source> ( - state: &T, token: &mut TokenIter<'source> - ) -> Perhaps { + impl<'n, A: 'n, T: Receive> Provide<'n, T> for $Enum { + fn provide <'source> (state: &T, token: &mut TokenIter<'source>) + -> Perhaps + { if let Some(Token { value: Value::Key(k), .. }) = token.peek() { let mut base = token.clone(); return Ok(Some(match token.next() { Some(Token{value:Value::Key($x),..}) => - Self::x(state.take_or_fail(token, ||"x: no content")?), + Self::x(state.receive_or_fail(token, ||"x: no content")?), Some(Token{value:Value::Key($y),..}) => - Self::y(state.take_or_fail(token, ||"y: no content")?), + Self::y(state.receive_or_fail(token, ||"y: no content")?), Some(Token{value:Value::Key($xy),..}) => - Self::xy(state.take_or_fail(token, ||"xy: no content")?), + Self::xy(state.receive_or_fail(token, ||"xy: no content")?), _ => unreachable!() })) } @@ -79,25 +79,25 @@ macro_rules! transform_xy_unit { #[inline] pub const fn xy (x: U, y: U, item: A) -> Self { Self::XY(x, y, item) } } #[cfg(feature = "dsl")] - impl + Dsl> Namespace for $Enum { - fn take_from <'source> ( + impl<'n, A: 'n, U: Coordinate + 'n, T: Receive + Receive> Provide<'n, T> for $Enum { + fn provide <'source> ( state: &T, token: &mut TokenIter<'source> ) -> Perhaps { Ok(if let Some(Token { value: Value::Key($x|$y|$xy), .. }) = token.peek() { let mut base = token.clone(); Some(match token.next() { Some(Token { value: Value::Key($x), .. }) => Self::x( - state.take_or_fail(token, ||"x: no unit")?, - state.take_or_fail(token, ||"x: no content")?, + state.receive_or_fail(token, ||"x: no unit")?, + state.receive_or_fail(token, ||"x: no content")?, ), Some(Token { value: Value::Key($y), .. }) => Self::y( - state.take_or_fail(token, ||"y: no unit")?, - state.take_or_fail(token, ||"y: no content")?, + state.receive_or_fail(token, ||"y: no unit")?, + state.receive_or_fail(token, ||"y: no content")?, ), Some(Token { value: Value::Key($x), .. }) => Self::xy( - state.take_or_fail(token, ||"xy: no unit x")?, - state.take_or_fail(token, ||"xy: no unit y")?, - state.take_or_fail(token, ||"xy: no content")? + state.receive_or_fail(token, ||"xy: no unit x")?, + state.receive_or_fail(token, ||"xy: no unit y")?, + state.receive_or_fail(token, ||"xy: no content")? ), _ => unreachable!(), }) diff --git a/output/src/ops/when.rs b/output/src/ops/when.rs index 35f1910..c2c0b1a 100644 --- a/output/src/ops/when.rs +++ b/output/src/ops/when.rs @@ -9,19 +9,17 @@ impl When { } } #[cfg(feature = "dsl")] -impl + Dsl> Namespace for When { - fn take_from <'source> ( - state: &T, - token: &mut TokenIter<'source> - ) -> Perhaps { +impl<'n, State: Receive + Receive, A: 'n> Provide<'n, State> for When { + fn provide <'source> (state: &State, words: &mut TokenIter<'source>) -> Perhaps { Ok(if let Some(Token { value: Value::Key("when"), .. - }) = token.peek() { - let base = token.clone(); + }) = words.peek() { + let _ = words.next(); + let base = words.clone(); return Ok(Some(Self( - state.take_or_fail(token, ||"cond: no condition")?, - state.take_or_fail(token, ||"cond: no content")?, + state.receive_or_fail(words, ||"cond: no condition")?, + state.receive_or_fail(words, ||"cond: no content")?, ))) } else { None diff --git a/proc/src/proc_command.rs b/proc/src/proc_command.rs index 95f7a42..e16146d 100644 --- a/proc/src/proc_command.rs +++ b/proc/src/proc_command.rs @@ -84,7 +84,7 @@ impl ToTokens for CommandDef { let mut out = TokenStream2::new(); for (arg, ty) in arm.args() { write_quote_to(&mut out, quote! { - #arg: Namespace::take_from_or_fail(self, words)?, + #arg: Provide::provide_or_fail(self, words)?, }); } out @@ -149,8 +149,8 @@ impl ToTokens for CommandDef { } } /// Generated by [tengri_proc::command]. - impl ::tengri::dsl::Namespace<#state> for #command_enum { - fn take_from <'source> ( + impl<'n> ::tengri::dsl::Provide<'n, #state> for #command_enum { + fn provide <'source> ( state: &#state, words: &mut ::tengri::dsl::TokenIter<'source> ) -> Perhaps { diff --git a/proc/src/proc_expose.rs b/proc/src/proc_expose.rs index bf951b5..6911a40 100644 --- a/proc/src/proc_expose.rs +++ b/proc/src/proc_expose.rs @@ -85,8 +85,8 @@ impl ToTokens for ExposeImpl { let values = variants.iter().map(ExposeArm::from); write_quote_to(out, quote! { /// Generated by [tengri_proc::expose]. - impl ::tengri::dsl::Namespace<#state> for #t { - fn take_from <'source> ( + impl<'n> ::tengri::dsl::Provide<'n, #state> for #t { + fn provide <'source> ( state: &#state, words: &mut ::tengri::dsl::TokenIter<'source> ) -> Perhaps { diff --git a/proc/src/proc_view.rs b/proc/src/proc_view.rs index ac18a80..a8d8f7a 100644 --- a/proc/src/proc_view.rs +++ b/proc/src/proc_view.rs @@ -46,7 +46,7 @@ impl ToTokens for ViewDef { let builtins: Vec<_> = builtins_with_types() .iter() .map(|ty|write_quote(quote! { - let value: Option<#ty> = Dsl::take(state, &mut exp.clone())?; + let value: Option<#ty> = Receive::<#ty>::receive(self, &mut exp.clone())?; if let Some(value) = value { return Ok(Some(value.boxed())) } @@ -55,30 +55,20 @@ impl ToTokens for ViewDef { let exposed: Vec<_> = exposed .iter() .map(|(key, value)|write_quote(quote! { - #key => Some(#self_ty::#value(state).boxed()), + #key => { + Some(Box::new(Thunk::new(move||#self_ty::#value(self))))//Box::new("todo")) + }, })).collect(); write_quote_to(out, quote! { - #block - /// Generated by [tengri_proc]. - /// - /// Delegates the rendering of [#self_ty] to the [#self_ty::view} method, - /// which you will need to implement, e.g. passing a [TokenIter] - /// containing a layout and keybindings config from user dirs. - impl ::tengri::output::Content<#output> for #self_ty { - fn content (&self) -> impl Render<#output> { - #self_ty::view(self) - } - } /// Generated by [tengri_proc]. /// /// Gives [#self_ty] the ability to construct the [Render]able /// which might corresponds to a given [TokenStream], /// while taking [#self_ty]'s state into consideration. - impl ::tengri::dsl::Namespace<#self_ty> for Box + '_> { - fn take_from <'source> ( - state: &#self_ty, - words: &mut ::tengri::dsl::TokenIter<'source> - ) -> Perhaps { + impl ::tengri::dsl::Receive>> for #self_ty { + fn receive <'source> (&self, words: &mut ::tengri::dsl::TokenIter<'source>) + -> Perhaps>> + { Ok(if let Some(::tengri::dsl::Token { value, .. }) = words.peek() { match value { // Expressions are handled by built-in functions @@ -100,6 +90,18 @@ impl ToTokens for ViewDef { }) } } + /// Generated by [tengri_proc]. + /// + /// Delegates the rendering of [#self_ty] to the [#self_ty::view} method, + /// which you will need to implement, e.g. passing a [TokenIter] + /// containing a layout and keybindings config from user dirs. + impl ::tengri::output::Content<#output> for #self_ty { + fn content (&self) -> impl Render<#output> + '_ { + #self_ty::view(self) + } + } + // Original user-provided implementation: + #block }) } }