blob: 4bd7492efb39cdc9e9f4147219a97e81ad33126f (
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_mut<'item_impl>(
item_impl: &'item_impl mut ItemImpl,
method_name: &'static str,
) -> Option<&'item_impl mut ImplItemMethod>
{
let impl_items = &mut item_impl.items;
impl_items.iter_mut().find_map(|impl_item| match impl_item {
ImplItem::Method(method_item) => {
if method_item.sig.ident == method_name {
Some(method_item)
} else {
None
}
}
&mut _ => None,
})
}
|