1use proc_macro2::TokenStream;
2use quote::ToTokens;
3
4pub(crate) struct TokensOrDefault<'a, T: 'a>(pub &'a Option<T>);
5
6impl<'a, T> ToTokens for TokensOrDefault<'a, T>
7where
8 T: ToTokens + Default,
9{
10 fn to_tokens(&self, tokens: &mut TokenStream) {
11 match self.0 {
12 Some(t) => t.to_tokens(tokens),
13 None => T::default().to_tokens(tokens),
14 }
15 }
16}
17