()
| 698 | |
| 699 | #[test] |
| 700 | fn test_extract_generic_struct() { |
| 701 | let mut parser = RustParser::new(); |
| 702 | let source = r#" |
| 703 | pub struct Cache<K, V> { |
| 704 | entries: HashMap<K, V>, |
| 705 | capacity: usize, |
| 706 | } |
| 707 | "#; |
| 708 | let entities = parser.extract(source, "src/cache.rs"); |
| 709 | let cache = entities.iter().find(|e| e.name == "Cache").unwrap(); |
| 710 | assert!( |
| 711 | cache.signature.as_ref().unwrap().contains("<K, V>"), |
| 712 | "Should include generics: {:?}", |
| 713 | cache.signature |
| 714 | ); |
| 715 | } |
| 716 | |
| 717 | #[test] |
| 718 | fn test_extract_enum() { |