[−][src]Function genco::tokens::from_fn
pub fn from_fn<F, L>(f: F) -> FromFn<F> where
F: FnOnce(&mut Tokens<L>),
L: Lang,
Construct a formatter from a function.
Examples
use genco::quote_in; use genco::lang::Lang; use genco::tokens::{ItemStr, FormatInto, from_fn, static_literal}; fn comment<L>(s: impl Into<ItemStr>) -> impl FormatInto<L> where L: Lang { from_fn(move |tokens| { let s = s.into(); quote_in!(*tokens => #(static_literal("//")) #s); }) }