[][src]Trait genco::tokens::FormatInto

pub trait FormatInto<L> where
    L: Lang
{ fn format_into(self, tokens: &mut Tokens<L>); }

Trait for types that can be formatted in-place into a token stream.

Things implementing FormatInto can be used as arguments for interpolation in the quote! macro.

from_fn() is a helper function which simplifies the task of creating a FormatInto implementation on the fly.

Examples

use genco::quote_in;
use genco::tokens::{ItemStr, FormatInto, from_fn, static_literal};
use genco::lang::Lang;

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);
    })
}

Required methods

fn format_into(self, tokens: &mut Tokens<L>)

Convert the type into tokens in-place.

Examples

Loading content...

Implementations on Foreign Types

impl<L> FormatInto<L> for Vec<Tokens<L>> where
    L: Lang
[src]

Convert collection to tokens.

impl<'a, L> FormatInto<L> for &'a str where
    L: Lang
[src]

Convert borrowed strings.

impl<'a, L> FormatInto<L> for &'a String where
    L: Lang
[src]

Convert borrowed strings.

impl<L> FormatInto<L> for String where
    L: Lang
[src]

Convert strings.

impl<L> FormatInto<L> for Rc<String> where
    L: Lang
[src]

Convert refcounted strings.

impl<'a, L> FormatInto<L> for &'a Rc<String> where
    L: Lang
[src]

Convert reference to refcounted strings.

impl<L, T> FormatInto<L> for Option<T> where
    L: Lang,
    T: FormatInto<L>, 
[src]

Convert stringy things.

impl<L> FormatInto<L> for u8 where
    L: Lang
[src]

impl<L> FormatInto<L> for u16 where
    L: Lang
[src]

impl<L> FormatInto<L> for u32 where
    L: Lang
[src]

impl<L> FormatInto<L> for u64 where
    L: Lang
[src]

impl<L> FormatInto<L> for u128 where
    L: Lang
[src]

impl<L> FormatInto<L> for i8 where
    L: Lang
[src]

impl<L> FormatInto<L> for i16 where
    L: Lang
[src]

impl<L> FormatInto<L> for i32 where
    L: Lang
[src]

impl<L> FormatInto<L> for i64 where
    L: Lang
[src]

impl<L> FormatInto<L> for i128 where
    L: Lang
[src]

impl<L> FormatInto<L> for isize where
    L: Lang
[src]

impl<L> FormatInto<L> for usize where
    L: Lang
[src]

Loading content...

Implementors

impl FormatInto<Csharp> for genco::lang::csharp::Import[src]

impl FormatInto<Dart> for genco::lang::dart::Import[src]

impl FormatInto<Go> for genco::lang::go::Import[src]

impl FormatInto<Java> for genco::lang::java::Import[src]

impl FormatInto<JavaScript> for genco::lang::js::Import[src]

impl FormatInto<Python> for genco::lang::python::Import[src]

impl FormatInto<Python> for ImportModule[src]

impl FormatInto<Rust> for genco::lang::rust::Import[src]

impl FormatInto<Swift> for genco::lang::swift::Import[src]

impl<'a> FormatInto<Csharp> for &'a genco::lang::csharp::Import[src]

impl<'a> FormatInto<Dart> for &'a genco::lang::dart::Import[src]

impl<'a> FormatInto<Go> for &'a genco::lang::go::Import[src]

impl<'a> FormatInto<Java> for &'a genco::lang::java::Import[src]

impl<'a> FormatInto<JavaScript> for &'a genco::lang::js::Import[src]

impl<'a> FormatInto<Python> for &'a genco::lang::python::Import[src]

impl<'a> FormatInto<Python> for &'a ImportModule[src]

impl<'a> FormatInto<Rust> for &'a genco::lang::rust::Import[src]

impl<'a> FormatInto<Swift> for &'a genco::lang::swift::Import[src]

impl<'a, L> FormatInto<L> for &'a ItemStr where
    L: Lang
[src]

impl<'a, L> FormatInto<L> for &'a Tokens<L> where
    L: Lang
[src]

impl<L> FormatInto<L> for Item<L> where
    L: Lang
[src]

impl<L> FormatInto<L> for ItemStr where
    L: Lang
[src]

Convert stringy things.

impl<L> FormatInto<L> for Tokens<L> where
    L: Lang
[src]

impl<L, F> FormatInto<L> for FromFn<F> where
    L: Lang,
    F: FnOnce(&mut Tokens<L>), 
[src]

impl<T> FormatInto<Csharp> for genco::lang::csharp::BlockComment<T> where
    T: IntoIterator,
    T::Item: Into<ItemStr>, 
[src]

impl<T> FormatInto<Csharp> for Comment<T> where
    T: IntoIterator,
    T::Item: Into<ItemStr>, 
[src]

impl<T> FormatInto<Dart> for DocComment<T> where
    T: IntoIterator,
    T::Item: Into<ItemStr>, 
[src]

impl<T> FormatInto<Java> for genco::lang::java::BlockComment<T> where
    T: IntoIterator,
    T::Item: Into<ItemStr>, 
[src]

impl<T, L> FormatInto<L> for Display<T> where
    L: Lang,
    T: Display
[src]

Loading content...