mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
Fix #[derive(DialogueState)]
This commit is contained in:
parent
f8b2f010c9
commit
19595c1e03
3 changed files with 59 additions and 53 deletions
|
@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## unreleased
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix the broken `#[derive(DialogueState)]` (function return type `dptree::Handler`).
|
||||
|
||||
## 0.8.1 - 2022-04-24
|
||||
|
||||
### Added
|
||||
|
|
|
@ -57,7 +57,7 @@ full = [
|
|||
|
||||
[dependencies]
|
||||
teloxide-core = { version = "0.5.1", default-features = false }
|
||||
teloxide-macros = { version = "0.6.0", optional = true }
|
||||
teloxide-macros = { git = "https://github.com/teloxide/teloxide-macros.git", rev = "a3e69b811e753d9f747aaefa7de40bf0c211bfb8", optional = true }
|
||||
|
||||
serde_json = "1.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
|
|
|
@ -1,62 +1,64 @@
|
|||
// #[cfg(feature = "macros")]
|
||||
// use teloxide::macros::DialogueState;
|
||||
// // We put tests here because macro expand in unit tests in the crate was a
|
||||
// // failure
|
||||
#![allow(deprecated)]
|
||||
|
||||
// #[test]
|
||||
// #[cfg(feature = "macros")]
|
||||
// fn compile_test() {
|
||||
// #[allow(dead_code)]
|
||||
// #[derive(DialogueState, Clone)]
|
||||
// #[handler_out(Result<(), teloxide::RequestError>)]
|
||||
// enum State {
|
||||
// #[handler(handle_start)]
|
||||
// Start,
|
||||
#[cfg(feature = "macros")]
|
||||
use teloxide::macros::DialogueState;
|
||||
// We put tests here because macro expand in unit tests in the crate was a
|
||||
// failure
|
||||
|
||||
// #[handler(handle_have_data)]
|
||||
// HaveData(String),
|
||||
// }
|
||||
#[test]
|
||||
#[cfg(feature = "macros")]
|
||||
fn compile_test() {
|
||||
#[allow(dead_code)]
|
||||
#[derive(DialogueState, Clone)]
|
||||
#[handler_out(Result<(), teloxide::RequestError>)]
|
||||
enum State {
|
||||
#[handler(handle_start)]
|
||||
Start,
|
||||
|
||||
// impl Default for State {
|
||||
// fn default() -> Self {
|
||||
// Self::Start
|
||||
// }
|
||||
// }
|
||||
#[handler(handle_have_data)]
|
||||
HaveData(String),
|
||||
}
|
||||
|
||||
// async fn handle_start() -> Result<(), teloxide::RequestError> {
|
||||
// Ok(())
|
||||
// }
|
||||
impl Default for State {
|
||||
fn default() -> Self {
|
||||
Self::Start
|
||||
}
|
||||
}
|
||||
|
||||
// async fn handle_have_data() -> Result<(), teloxide::RequestError> {
|
||||
// Ok(())
|
||||
// }
|
||||
// }
|
||||
async fn handle_start() -> Result<(), teloxide::RequestError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// #[test]
|
||||
// #[cfg(feature = "macros")]
|
||||
// fn compile_test_generics() {
|
||||
// #[allow(dead_code)]
|
||||
// #[derive(DialogueState, Clone)]
|
||||
// #[handler_out(Result<(), teloxide::RequestError>)]
|
||||
// enum State<X: Clone + Send + Sync + 'static> {
|
||||
// #[handler(handle_start)]
|
||||
// Start,
|
||||
async fn handle_have_data() -> Result<(), teloxide::RequestError> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
// #[handler(handle_have_data)]
|
||||
// HaveData(X),
|
||||
// }
|
||||
#[test]
|
||||
#[cfg(feature = "macros")]
|
||||
fn compile_test_generics() {
|
||||
#[allow(dead_code)]
|
||||
#[derive(DialogueState, Clone)]
|
||||
#[handler_out(Result<(), teloxide::RequestError>)]
|
||||
enum State<X: Clone + Send + Sync + 'static> {
|
||||
#[handler(handle_start)]
|
||||
Start,
|
||||
|
||||
// impl<X: Clone + Send + Sync + 'static> Default for State<X> {
|
||||
// fn default() -> Self {
|
||||
// Self::Start
|
||||
// }
|
||||
// }
|
||||
#[handler(handle_have_data)]
|
||||
HaveData(X),
|
||||
}
|
||||
|
||||
// async fn handle_start() -> Result<(), teloxide::RequestError> {
|
||||
// Ok(())
|
||||
// }
|
||||
impl<X: Clone + Send + Sync + 'static> Default for State<X> {
|
||||
fn default() -> Self {
|
||||
Self::Start
|
||||
}
|
||||
}
|
||||
|
||||
// async fn handle_have_data() -> Result<(), teloxide::RequestError> {
|
||||
// Ok(())
|
||||
// }
|
||||
// }
|
||||
async fn handle_start() -> Result<(), teloxide::RequestError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn handle_have_data() -> Result<(), teloxide::RequestError> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue