ferment_sys/ext/abstract/
accessory.rs

1use quote::ToTokens;
2use syn::{parse_quote, Type};
3use syn::__private::TokenStream2;
4
5pub trait Accessory: ToTokens {
6    fn joined_mut(&self) -> Self;
7    #[allow(unused)]
8    fn joined_const(&self) -> Self;
9    #[allow(unused)]
10    fn joined_dyn(&self) -> Self;
11}
12#[macro_export]
13macro_rules! impl_accessory {
14    ($ty:ty) => {
15        impl crate::ext::Accessory for $ty {
16            fn joined_mut(&self) -> Self {
17                parse_quote!(*mut #self)
18            }
19            fn joined_const(&self) -> Self {
20                parse_quote!(*const #self)
21            }
22            fn joined_dyn(&self) -> Self {
23                parse_quote!(dyn #self)
24            }
25        }
26    };
27}
28impl_accessory!(Type);
29impl_accessory!(TokenStream2);