rsproject/Relm4-0.6.2/relm4-macros/src/widgets/parse/widget_func_method.rs
2024-03-02 00:19:08 +08:00

26 lines
654 B
Rust

use syn::parse::{Parse, ParseStream};
use syn::punctuated::Punctuated;
use syn::{parenthesized, token, Result};
use crate::widgets::WidgetFuncMethod;
impl Parse for WidgetFuncMethod {
fn parse(input: ParseStream<'_>) -> Result<Self> {
let ident = input.parse()?;
let turbofish = input.parse().ok();
let args = if input.peek(token::Paren) {
let inner_input;
parenthesized!(inner_input in input);
Some(Punctuated::parse_terminated(&inner_input)?)
} else {
None
};
Ok(Self {
ident,
turbofish,
args,
})
}
}