move parenthesized to its own module

This commit is contained in:
Niko Matsakis 2019-01-21 07:40:00 -05:00
parent d510b28fe2
commit d15be76350
3 changed files with 14 additions and 13 deletions

View file

@ -9,6 +9,7 @@ extern crate quote;
use proc_macro::TokenStream; use proc_macro::TokenStream;
mod parenthesized;
mod query_group; mod query_group;
/// The decorator that defines a salsa "query group" trait. This is a /// The decorator that defines a salsa "query group" trait. This is a

View file

@ -0,0 +1,12 @@
pub(crate) struct Parenthesized<T>(pub T);
impl<T> syn::parse::Parse for Parenthesized<T>
where
T: syn::parse::Parse,
{
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
let content;
syn::parenthesized!(content in input);
content.parse::<T>().map(Parenthesized)
}
}

View file

@ -1,3 +1,4 @@
use crate::parenthesized::Parenthesized;
use heck::CamelCase; use heck::CamelCase;
use proc_macro::TokenStream; use proc_macro::TokenStream;
use proc_macro2::Span; use proc_macro2::Span;
@ -258,16 +259,3 @@ enum QueryStorage {
Dependencies, Dependencies,
Input, Input,
} }
struct Parenthesized<T>(pub T);
impl<T> syn::parse::Parse for Parenthesized<T>
where
T: syn::parse::Parse,
{
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
let content;
syn::parenthesized!(content in input);
content.parse::<T>().map(Parenthesized)
}
}