[][src]Trait genco::Quoted

pub trait Quoted<'el> {
    fn quoted(self) -> ErasedElement<'el>;
}

Trait to provide string quoting through <stmt>.quoted().

This is used to generated quoted strings, in the language of choice.

Examples

Example showcasing quoted strings when generating Rust.

#![feature(proc_macro_hygiene)]
use genco::prelude::*;
use genco::rust::imported;

let map = imported("std::collections", "HashMap").qualified();

let tokens = genco::quote! {
    let mut m = #map::<u32, &str>::new();
    m.insert(0, #("hello\" world".quoted()));
};

assert_eq!(
   vec![
       "use std::collections::HashMap;",
       "",
       "let mut m = HashMap::<u32, &str>::new();",
       "m.insert(0, \"hello\\\" world\");",
       ""
    ],
    tokens.to_file_vec().unwrap(),
);

Required methods

fn quoted(self) -> ErasedElement<'el>

Convert type to quoted element.

Loading content...

Implementations on Foreign Types

impl<'el> Quoted<'el> for String[src]

impl<'el> Quoted<'el> for &'el str[src]

impl<'el> Quoted<'el> for Rc<String>[src]

Loading content...

Implementors

impl<'el> Quoted<'el> for Cons<'el>[src]

Loading content...