use syn::parse::{Parse, ParseStream}; use syn::{braced, Ident, Token, TraitItem, TypePath, WhereClause}; pub struct MockInput { pub mock: Ident, pub mocked_trait: TypePath, pub items: Vec, } impl Parse for MockInput { fn parse(input: ParseStream) -> Result { let mock = input.parse()?; let _generics = input.parse::>()?; let _braced_content; let _brace = braced!(_braced_content in input); input.parse::()?; let mocked_trait = input.parse()?; input.parse::()?; let impl_target = input.parse::()?; if impl_target != mock { return Err(input.error("Expected this to be the mock")); } let content; braced!(content in input); let mut items = Vec::new(); while !content.is_empty() { items.push(content.parse()?); } Ok(Self { mock, mocked_trait, items, }) } }