mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-23 06:51:01 +01:00
I previous commit I accidentally run cargo +stable fmt
(instead of +nightly
) and forgot std::
in one of imports. This commit fixes both problems.
This commit is contained in:
parent
03967493f6
commit
08375a3eff
4 changed files with 22 additions and 31 deletions
|
@ -1,6 +1,5 @@
|
||||||
// used instead of `!` to be compatible with rust <1.41
|
// Infallible used here instead of `!` to be compatible with rust <1.41
|
||||||
use convert::Infallible;
|
use std::{convert::Infallible, future::Future, pin::Pin};
|
||||||
use std::{future::Future, pin::Pin};
|
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
|
|
||||||
|
|
|
@ -318,16 +318,12 @@ mod tests {
|
||||||
let counter2 = &AtomicI32::new(0);
|
let counter2 = &AtomicI32::new(0);
|
||||||
|
|
||||||
let mut dp = FilterDispatcher::<Infallible, _>::new(|_| async {})
|
let mut dp = FilterDispatcher::<Infallible, _>::new(|_| async {})
|
||||||
.message_handler(true, |_mes: Message| {
|
.message_handler(true, |_mes: Message| async move {
|
||||||
async move {
|
counter.fetch_add(1, Ordering::SeqCst);
|
||||||
counter.fetch_add(1, Ordering::SeqCst);
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.message_handler(true, |_mes: Message| {
|
.message_handler(true, |_mes: Message| async move {
|
||||||
async move {
|
counter2.fetch_add(1, Ordering::SeqCst);
|
||||||
counter2.fetch_add(1, Ordering::SeqCst);
|
Ok::<_, Infallible>(())
|
||||||
Ok::<_, Infallible>(())
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
dp.dispatch(one_message_updater()).await;
|
dp.dispatch(one_message_updater()).await;
|
||||||
|
|
|
@ -136,19 +136,17 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn polling<'a>(bot: &'a Bot) -> impl Updater<Error = RequestError> + 'a {
|
pub fn polling<'a>(bot: &'a Bot) -> impl Updater<Error = RequestError> + 'a {
|
||||||
let stream = stream::unfold((bot, 0), |(bot, mut offset)| {
|
let stream = stream::unfold((bot, 0), |(bot, mut offset)| async move {
|
||||||
async move {
|
let updates = match bot.get_updates().offset(offset).send().await {
|
||||||
let updates = match bot.get_updates().offset(offset).send().await {
|
Ok(updates) => {
|
||||||
Ok(updates) => {
|
if let Some(upd) = updates.last() {
|
||||||
if let Some(upd) = updates.last() {
|
offset = upd.id + 1;
|
||||||
offset = upd.id + 1;
|
|
||||||
}
|
|
||||||
updates.into_iter().map(Ok).collect::<Vec<_>>()
|
|
||||||
}
|
}
|
||||||
Err(err) => vec![Err(err)],
|
updates.into_iter().map(Ok).collect::<Vec<_>>()
|
||||||
};
|
}
|
||||||
Some((stream::iter(updates), (bot, offset)))
|
Err(err) => vec![Err(err)],
|
||||||
}
|
};
|
||||||
|
Some((stream::iter(updates), (bot, offset)))
|
||||||
})
|
})
|
||||||
.flatten();
|
.flatten();
|
||||||
|
|
||||||
|
|
|
@ -42,13 +42,11 @@ pub async fn download_file_stream(
|
||||||
.await?
|
.await?
|
||||||
.error_for_status()?;
|
.error_for_status()?;
|
||||||
|
|
||||||
Ok(futures::stream::unfold(res, |mut res| {
|
Ok(futures::stream::unfold(res, |mut res| async {
|
||||||
async {
|
match res.chunk().await {
|
||||||
match res.chunk().await {
|
Err(err) => Some((Err(err), res)),
|
||||||
Err(err) => Some((Err(err), res)),
|
Ok(Some(c)) => Some((Ok(c), res)),
|
||||||
Ok(Some(c)) => Some((Ok(c), res)),
|
Ok(None) => None,
|
||||||
Ok(None) => None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue