Merge pull request #27 from teloxide/fix-parse-with-path

Allow specifying a path to a command handler in `parse_with`
This commit is contained in:
Waffle Maybe 2022-07-19 19:55:45 +04:00 committed by GitHub
commit 4274eeeba9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View file

@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## unreleased
### Fixed
- Allow specifying a path to a command handler in `parse_with` ([PR #27](https://github.com/teloxide/teloxide-macros/pull/27)).
## 0.6.2 - 2022-05-27
### Fixed

View file

@ -1,6 +1,6 @@
extern crate quote;
use quote::{__private::Span, quote, ToTokens};
use quote::{quote, ToTokens};
use syn::{FieldsNamed, FieldsUnnamed, Type};
#[derive(Debug)]
@ -89,8 +89,10 @@ fn create_parser<'a>(
count_args,
),
ParserType::Custom(s) => {
let ident = syn::Ident::new(s, Span::call_site());
quote! { #ident }
let path = syn::parse_str::<syn::Path>(s).unwrap_or_else(|_| {
panic!("Failed to parse a custom command parser, {}", s)
});
quote! { #path }
}
};
quote! {