Skip to content

aatifsyed/derive-quote-to-tokens

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#[derive(ToTokens)], calling quote::ToTokens on each field. Nothing more, nothing less.

use derive_quote_to_tokens::ToTokens;
use quote::{ToTokens, quote};
use proc_macro2::Span;
use syn::{Token, Ident};

#[derive(ToTokens)]
struct Tag {
    lt: Token![<],
    inner: Ident,
    gt: Token![>],
}

let tag = /* snip */
assert_eq!(
    tag.to_token_stream().to_string(),
    quote! { <main> }.to_string(),
);

Enums work too.

#[derive(ToTokens)]
enum Arrow {
     Left(Token![<], Token![-]),
    Right(Token![-], Token![>]),
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages