From 153be9be65201827b114479efb4a7418487894a9 Mon Sep 17 00:00:00 2001 From: Youknow-sys Date: Thu, 8 Oct 2026 04:41:34 +0330 Subject: [PATCH] Rename `BoxFuture` to `MaybeSendBoxFuture` to not have the same name as `futures::future::BoxFuture` --- CHANGELOG.md | 1 + src/di.rs | 7 ++++--- src/handler/core.rs | 4 ++-- src/send.rs | 7 ++----- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 346dd4e..1b5b6f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Support for the `wasm32-unknown-unknown` target via `MaybeSend`/`MaybeSync` traits and a conditional `BoxFuture` alias ([PR #38](https://github.com/teloxide/dptree/issues/38)). - Fallible handlers `try_filter`, `try_map`, `try_filter_map` (and their `_async` variants), which let a function return `Result` and short-circuit the whole handler chain with `ControlFlow::Break` on `Err`. Requires the handler `Output` to implement the new `Fallible` trait. - The `Fallible` trait (with a blanket implementation for `Result`), used by the fallible handlers to build the `Err` half of the output. + - Rename `BoxFuture` to `MaybeSendBoxFuture` to not have the same name as `futures::future::BoxFuture`. ## 0.5.1 - 2025-07-10 diff --git a/src/di.rs b/src/di.rs index 7bdf57a..89fb197 100644 --- a/src/di.rs +++ b/src/di.rs @@ -15,7 +15,7 @@ use futures::future::ready; -use crate::send::{BoxFuture, MaybeSend, MaybeSync}; +use crate::send::{MaybeSend, MaybeSendBoxFuture, MaybeSync}; use std::{ any::{Any, TypeId}, @@ -204,9 +204,10 @@ where /// A function with all dependencies satisfied. #[cfg(not(target_arch = "wasm32"))] -pub type CompiledFn<'a, Output> = Arc BoxFuture<'a, Output> + Send + Sync + 'a>; +pub type CompiledFn<'a, Output> = + Arc MaybeSendBoxFuture<'a, Output> + Send + Sync + 'a>; #[cfg(target_arch = "wasm32")] -pub type CompiledFn<'a, Output> = Arc BoxFuture<'a, Output> + 'a>; +pub type CompiledFn<'a, Output> = Arc MaybeSendBoxFuture<'a, Output> + 'a>; /// Turns a synchronous function into a type that implements [`Injectable`]. pub struct Asyncify(pub F); diff --git a/src/handler/core.rs b/src/handler/core.rs index d4fd421..4043cde 100644 --- a/src/handler/core.rs +++ b/src/handler/core.rs @@ -6,7 +6,7 @@ const FIXED_LOCATION: &Location = Location::caller(); use crate::{ description, prelude::DependencyMap, - send::{BoxFuture, MaybeSend, MaybeSync}, + send::{MaybeSend, MaybeSendBoxFuture, MaybeSync}, HandlerDescription, }; @@ -139,7 +139,7 @@ type ContInner<'a, Output> = type ContInner<'a, Output> = Box HandlerResult<'a, Output> + 'a>; /// An output type produced by a handler. -pub type HandlerResult<'a, Output> = BoxFuture<'a, ControlFlow>; +pub type HandlerResult<'a, Output> = MaybeSendBoxFuture<'a, ControlFlow>; // `#[derive(Clone)]` obligates all type parameters to satisfy `Clone` as well, // but we do not need it here because of `Arc`. diff --git a/src/send.rs b/src/send.rs index 29ab792..adeff7f 100644 --- a/src/send.rs +++ b/src/send.rs @@ -1,8 +1,5 @@ //! Conditional `Send`/`Sync` helpers for wasm32 target. -use std::future::Future; -use std::pin::Pin; - /// `Send` on native targets; no bound on `wasm32`. #[cfg(not(target_arch = "wasm32"))] pub trait MaybeSend: Send {} @@ -30,6 +27,6 @@ impl MaybeSync for T {} /// A boxed future that is `Send` on native targets and not required to be `Send` /// on `wasm32`. #[cfg(not(target_arch = "wasm32"))] -pub type BoxFuture<'a, T> = Pin + Send + 'a>>; +pub type MaybeSendBoxFuture<'a, T> = futures::future::BoxFuture<'a, T>; #[cfg(target_arch = "wasm32")] -pub type BoxFuture<'a, T> = Pin + 'a>>; +pub type MaybeSendBoxFuture<'a, T> = futures::future::LocalBoxFuture<'a, T>;