syn_ext/
path.rs

1use crate::ident::GetIdent;
2use syn::{Ident, Path};
3
4/// Shortcut to get [syn::Path] from various types
5pub trait GetPath {
6    /// Returns [syn::Path] from object if possible
7    fn get_path(&self) -> Option<&Path>;
8}
9
10impl<T> GetIdent for T
11where
12    T: GetPath,
13{
14    /// Any [crate::ext::GetPath] automatically implements [crate::ext::GetIdent]
15    fn get_ident(&self) -> Option<&Ident> {
16        self.get_path().and_then(|p| p.get_ident())
17    }
18}