2 releases
0.1.1 | Mar 17, 2024 |
---|---|
0.1.0 | Sep 22, 2023 |
#96 in #quote
44 downloads per month
Used in 5 crates
(3 directly)
7KB
101 lines
#[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![>]),
}
lib.rs
:
#[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![>]),
}
Dependencies
~320–780KB
~18K SLoC