derive_deftly_macros/compat_syn_common.rs
1//! Definitions for compatibility with syn, common to 1 and 2
2
3use super::prelude::*;
4
5//---------- Attribute handling ----------
6
7/// Helper trait to deal with syn's idea of attribute contents
8///
9/// We expect all our attributes to be parenthesised.
10pub trait AttributeExt12 {
11 /// Parse the content within an `#[attribute(content)]`
12 ///
13 /// Parses the `content` as `T`.
14 fn parse_in_parens<T: Parse>(&self) -> syn::Result<T> {
15 self.call_in_parens(Parse::parse)
16 }
17
18 /// Like `parse_in_parens`, but takes a parser callback.
19 fn call_in_parens<T, F>(&self, f: F) -> syn::Result<T>
20 where
21 F: FnOnce(ParseStream<'_>) -> syn::Result<T>;
22}