blob: 271ae2f10f0c4fad3f4a5acfa6624975e1cd6462 (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 | use syn::{ImplItem, ImplItemMethod, ItemImpl};
pub fn find_impl_method_by_name<'item_impl>(
    item_impl: &'item_impl ItemImpl,
    method_name: &'static str,
) -> Option<&'item_impl ImplItemMethod>
{
    let impl_items = &item_impl.items;
    impl_items.iter().find_map(|impl_item| match impl_item {
        ImplItem::Method(method_item) => {
            if method_item.sig.ident == method_name {
                Some(method_item)
            } else {
                None
            }
        }
        &_ => None,
    })
}
 |