macro_rules! parse_item_fn {
($($args:tt)*) => { ... };
}Expand description
Parse an item fn
Example:
macro_rules! expect_item_fn {
(
item_fn {
$(outer_attrs { #[cfg(..)] })? // present if there are outer attributes
vis {$vis:tt}
sig {
// the following keywords are present if specified
$(default {default})?
$(const {const} )?
$(async {async} )?
$(unsafe {unsafe} )?
$(extern {extern $($extern_name:literal)?})?
fn { fn }
ident { get }
$( // present if there is `<...>`
lt {<}
parsed_generics $parsed_generics:tt
gt {>}
)?
paren_inputs { (self) }
output { $(-> $output_ty:ty)? }
$( // present if there is where clause
where_clause { where $($where_clause:tt)* }
)?
}
// either block or semicolon will be present
$(block { {..} })? // present if there is a block as fn body
$(semicolon { ; })? // present if there is a semicolon
}
rest {}
) => {};
}
syn_lite::parse_item_fn! {
on_finish { expect_item_fn! }
input {
#[cfg(..)]
fn get<T>(self) -> Option<T>
where
Self: Sized,
{
..
}
}
}