ferment_sys/ext/abstract/
accessory.rs1use 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 #[allow(unused)]
13 fn joined_ref(&self) -> Self;
14
15 #[allow(unused)]
16 fn joined_mut_ref(&self) -> Self;
17}
18#[macro_export]
19macro_rules! impl_accessory {
20 ($ty:ty) => {
21 impl crate::ext::Accessory for $ty {
22 fn joined_mut(&self) -> Self {
23 parse_quote!(*mut #self)
24 }
25 fn joined_const(&self) -> Self {
26 parse_quote!(*const #self)
27 }
28 fn joined_dyn(&self) -> Self {
29 parse_quote!(dyn #self)
30 }
31 fn joined_ref(&self) -> Self {
32 parse_quote!(&#self)
33 }
34 fn joined_mut_ref(&self) -> Self {
35 parse_quote!(&mut #self)
36 }
37 }
38 };
39}
40impl_accessory!(Type);
41impl_accessory!(TokenStream2);