rune/ast/
fn_arg.rs
1use crate::ast::prelude::*;
2
3#[test]
4#[cfg(not(miri))]
5fn ast_parse() {
6 rt::<ast::FnArg>("self");
7 rt::<ast::FnArg>("_");
8 rt::<ast::FnArg>("abc");
9}
10
11#[derive(Debug, TryClone, PartialEq, Eq, ToTokens, Spanned)]
13#[non_exhaustive]
14pub enum FnArg {
15 SelfValue(T![self]),
17 Pat(ast::Pat),
19}
20
21impl Parse for FnArg {
22 fn parse(p: &mut Parser<'_>) -> Result<Self> {
23 Ok(match p.nth(0)? {
24 K![self] => Self::SelfValue(p.parse()?),
25 _ => Self::Pat(p.parse()?),
26 })
27 }
28}