| 1 | use quote::quote_spanned; |
| 2 | use syn::{spanned::Spanned, Type}; |
| 3 | |
| 4 | use crate::common::{r#type::dereference_changed, tools::HashType}; |
| 5 | |
| 6 | #[inline] |
| 7 | pub(crate) fn to_hash_type(ty: &Type) -> HashType { |
| 8 | let (ty, is_ref) = dereference_changed(ty); |
| 9 | |
| 10 | let ty = if is_ref { |
| 11 | syn::parse2(quote_spanned!( ty.span() => &'static #ty )).unwrap() |
| 12 | } else { |
| 13 | ty.clone() |
| 14 | }; |
| 15 | |
| 16 | HashType::from(ty) |
| 17 | } |