diff --git a/components/salsa-macros/src/lib.rs b/components/salsa-macros/src/lib.rs index abb1a5c0..fa0d17ef 100644 --- a/components/salsa-macros/src/lib.rs +++ b/components/salsa-macros/src/lib.rs @@ -9,6 +9,7 @@ extern crate quote; use proc_macro::TokenStream; +mod parenthesized; mod query_group; /// The decorator that defines a salsa "query group" trait. This is a diff --git a/components/salsa-macros/src/parenthesized.rs b/components/salsa-macros/src/parenthesized.rs new file mode 100644 index 00000000..e9817644 --- /dev/null +++ b/components/salsa-macros/src/parenthesized.rs @@ -0,0 +1,12 @@ +pub(crate) struct Parenthesized(pub T); + +impl syn::parse::Parse for Parenthesized +where + T: syn::parse::Parse, +{ + fn parse(input: syn::parse::ParseStream) -> syn::Result { + let content; + syn::parenthesized!(content in input); + content.parse::().map(Parenthesized) + } +} diff --git a/components/salsa-macros/src/query_group.rs b/components/salsa-macros/src/query_group.rs index bbc7a9c6..62b4b237 100644 --- a/components/salsa-macros/src/query_group.rs +++ b/components/salsa-macros/src/query_group.rs @@ -1,3 +1,4 @@ +use crate::parenthesized::Parenthesized; use heck::CamelCase; use proc_macro::TokenStream; use proc_macro2::Span; @@ -258,16 +259,3 @@ enum QueryStorage { Dependencies, Input, } - -struct Parenthesized(pub T); - -impl syn::parse::Parse for Parenthesized -where - T: syn::parse::Parse, -{ - fn parse(input: syn::parse::ParseStream) -> syn::Result { - let content; - syn::parenthesized!(content in input); - content.parse::().map(Parenthesized) - } -}