You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the way to create an implementation is to create a new Trait structure with a vector of TraitItems with their respective handlers. The handlers are call-backs that are fired for every structure.
These handlers are currently imperative in the way the handler evaluates the input and reads the data to generate a token stream. A possible way could be to generate a trait and it's handlers using a declarative form from a TokenStream generated by quote:
let my_trait = Trait::from_tokens(quote!{trait::my_crate::MyTrait{fn method_one(&self){
#(do_thing(self.*);)*}}});
This should be possible by creating a ComputedBody struct which implements for<'a> Fn(Item<'a>) -> HandlerResult and evaluates based on the declaration in the token stream.
Few complications:
How to do a basic set of things declarative
Where to draw the line as to where an imperiative implementation is required
How to parse the token stream especially function bodies
The text was updated successfully, but these errors were encountered:
Currently the way to create an implementation is to create a new
Trait
structure with a vector ofTraitItem
s with their respective handlers. The handlers are call-backs that are fired for every structure.These handlers are currently imperative in the way the handler evaluates the input and reads the data to generate a token stream. A possible way could be to generate a trait and it's handlers using a declarative form from a
TokenStream
generated byquote
:This should be possible by creating a
ComputedBody
struct which implementsfor<'a> Fn(Item<'a>) -> HandlerResult
and evaluates based on the declaration in the token stream.Few complications:
The text was updated successfully, but these errors were encountered: