| David Tolnay | 3abed47 | 2020-12-31 23:34:53 -0800 | [diff] [blame^] | 1 | use crate::syntax::{NamedType, Pair, Types}; |
| 2 | use proc_macro2::Ident; |
| 3 | |
| 4 | impl<'a> Types<'a> { |
| 5 | pub fn resolve(&self, ident: &impl UnresolvedName) -> &Pair { |
| 6 | self.resolutions |
| 7 | .get(ident.ident()) |
| 8 | .expect("Unable to resolve type") |
| 9 | } |
| 10 | } |
| 11 | |
| 12 | pub trait UnresolvedName { |
| 13 | fn ident(&self) -> &Ident; |
| 14 | } |
| 15 | |
| 16 | impl UnresolvedName for Ident { |
| 17 | fn ident(&self) -> &Ident { |
| 18 | self |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | impl UnresolvedName for NamedType { |
| 23 | fn ident(&self) -> &Ident { |
| 24 | &self.rust |
| 25 | } |
| 26 | } |