Sha256: 22910bf0521ab868ebd7c62601c55912d12cfb400c65723e08e5cfa3a2d111c0
Contents?: true
Size: 390 Bytes
Versions: 33
Compression:
Stored size: 390 Bytes
Contents
use proc_macro2::TokenStream; use quote::ToTokens; pub(crate) struct TokensOrDefault<'a, T: 'a>(pub &'a Option<T>); impl<'a, T> ToTokens for TokensOrDefault<'a, T> where T: ToTokens + Default, { fn to_tokens(&self, tokens: &mut TokenStream) { match self.0 { Some(t) => t.to_tokens(tokens), None => T::default().to_tokens(tokens), } } }
Version data entries
33 entries across 33 versions & 1 rubygems