mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
small fixes
This commit is contained in:
parent
7d3a0ca7eb
commit
50b2b73f26
2 changed files with 6 additions and 4 deletions
|
@ -46,6 +46,7 @@
|
|||
//! [examples/admin_bot]: https://github.com/teloxide/teloxide/blob/master/examples/admin_bot/
|
||||
|
||||
pub use teloxide_macros::BotCommand;
|
||||
use std::error::Error;
|
||||
|
||||
/// An enumeration of bot's commands.
|
||||
///
|
||||
|
@ -161,13 +162,14 @@ pub use teloxide_macros::BotCommand;
|
|||
/// len => Err(ParseError::Custom(format!(
|
||||
/// "Only 2 digits allowed, not {}",
|
||||
/// len
|
||||
/// ))),
|
||||
/// ).into())),
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// #[derive(BotCommand, PartialEq, Debug)]
|
||||
/// #[command(rename = "lowercase", parser = "split")]
|
||||
/// #[command(rename = "lowercase")]
|
||||
/// enum Command {
|
||||
/// #[command(parser = "accept_two_digits")]
|
||||
/// Num(u8),
|
||||
/// }
|
||||
///
|
||||
|
@ -217,7 +219,7 @@ pub enum ParseError {
|
|||
WrongBotName(String),
|
||||
|
||||
/// A custom error which you can return from your custom parser.
|
||||
Custom(String),
|
||||
Custom(Box<dyn Error>),
|
||||
}
|
||||
|
||||
/// Parses a string into a command with args.
|
||||
|
|
|
@ -132,7 +132,7 @@ fn parse_custom_parser() {
|
|||
_ => return Err(ParseError::IncorrectFormat),
|
||||
};
|
||||
left.parse::<u8>().map(|res| (res, right.to_string())).map_err(|_| {
|
||||
ParseError::Custom("First argument must be a integer!".to_owned())
|
||||
ParseError::Custom("First argument must be a integer!".to_owned().into())
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue