mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-14 11:44:04 +01:00
async { ... }.boxed() -> Box::pin(async { ... })
This commit is contained in:
parent
9cb44bef0d
commit
e33bbeb027
5 changed files with 14 additions and 16 deletions
|
@ -27,6 +27,6 @@ where
|
|||
where
|
||||
DialogueWithCx<Upd, D, E>: Send + 'static,
|
||||
{
|
||||
async move { self(cx).await }.boxed()
|
||||
Box::pin(async move { self(cx).await })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ impl<D> Storage<D> for InMemStorage<D> {
|
|||
where
|
||||
D: Send + 'static,
|
||||
{
|
||||
async move { Ok(self.map.lock().await.remove(&chat_id)) }.boxed()
|
||||
Box::pin(async move { Ok(self.map.lock().await.remove(&chat_id)) })
|
||||
}
|
||||
|
||||
fn update_dialogue(
|
||||
|
@ -43,6 +43,6 @@ impl<D> Storage<D> for InMemStorage<D> {
|
|||
where
|
||||
D: Send + 'static,
|
||||
{
|
||||
async move { Ok(self.map.lock().await.insert(chat_id, dialogue)) }.boxed()
|
||||
Box::pin(async move { Ok(self.map.lock().await.insert(chat_id, dialogue)) })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ where
|
|||
self: Arc<Self>,
|
||||
chat_id: i64,
|
||||
) -> BoxFuture<'static, Result<Option<D>, Self::Error>> {
|
||||
async move {
|
||||
Box::pin(async move {
|
||||
let res = redis::pipe()
|
||||
.atomic()
|
||||
.get(chat_id)
|
||||
|
@ -80,7 +80,7 @@ where
|
|||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}.boxed()
|
||||
})
|
||||
}
|
||||
|
||||
fn update_dialogue(
|
||||
|
@ -88,7 +88,7 @@ where
|
|||
chat_id: i64,
|
||||
dialogue: D,
|
||||
) -> BoxFuture<'static, Result<Option<D>, Self::Error>> {
|
||||
async move {
|
||||
Box::pin(async move {
|
||||
let dialogue =
|
||||
self.serializer.serialize(&dialogue).map_err(RedisStorageError::SerdeError)?;
|
||||
Ok(self
|
||||
|
@ -99,7 +99,6 @@ where
|
|||
.await?
|
||||
.map(|d| self.serializer.deserialize(&d).map_err(RedisStorageError::SerdeError))
|
||||
.transpose()?)
|
||||
}
|
||||
.boxed()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,6 @@ where
|
|||
where
|
||||
UpdateWithCx<Upd>: Send + 'static,
|
||||
{
|
||||
async move { self(updates).await }.boxed()
|
||||
Box::pin(async move { self(updates).await })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ where
|
|||
Fut: Future<Output = ()> + Send,
|
||||
{
|
||||
fn handle_error(self: Arc<Self>, error: E) -> BoxFuture<'static, ()> {
|
||||
async move { self(error).await }.boxed()
|
||||
Box::pin(async move { self(error).await })
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,12 +81,11 @@ where
|
|||
Eh: ErrorHandler<E> + Send + Sync,
|
||||
Arc<Eh>: 'a,
|
||||
{
|
||||
async move {
|
||||
Box::pin(async move {
|
||||
if let Err(error) = self {
|
||||
eh.handle_error(error).await;
|
||||
}
|
||||
}
|
||||
.boxed()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,7 +114,7 @@ impl IgnoringErrorHandler {
|
|||
|
||||
impl<E> ErrorHandler<E> for IgnoringErrorHandler {
|
||||
fn handle_error(self: Arc<Self>, _: E) -> BoxFuture<'static, ()> {
|
||||
async {}.boxed()
|
||||
Box::pin(async {})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,7 +160,7 @@ impl IgnoringErrorHandlerSafe {
|
|||
#[allow(unreachable_code)]
|
||||
impl ErrorHandler<Infallible> for IgnoringErrorHandlerSafe {
|
||||
fn handle_error(self: Arc<Self>, _: Infallible) -> BoxFuture<'static, ()> {
|
||||
async {}.boxed()
|
||||
Box::pin(async {})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -208,6 +207,6 @@ where
|
|||
{
|
||||
fn handle_error(self: Arc<Self>, error: E) -> BoxFuture<'static, ()> {
|
||||
log::error!("{text}: {:?}", error, text = self.text);
|
||||
async {}.boxed()
|
||||
Box::pin(async {})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue