This commit is contained in:
p0lunin 2020-01-10 12:26:48 +02:00
parent cadd781abf
commit 80a9ebebd2
3 changed files with 18 additions and 12 deletions

View file

@ -31,9 +31,10 @@ type FiltersWithHandlers<'a, T, E> = Vec<FilterWithHandler<'a, T, E>>;
/// use std::convert::Infallible; /// use std::convert::Infallible;
/// use teloxide::{dispatching::FilterDispatcher, RequestError}; /// use teloxide::{dispatching::FilterDispatcher, RequestError};
/// ///
/// let _ = /// let _ = FilterDispatcher::new(|err: Either<RequestError, Infallible>| {
/// FilterDispatcher::new(|err: Either<RequestError, Infallible>| async { /// async {
/// dbg!(err); /// dbg!(err);
/// }
/// }); /// });
/// ``` /// ```
/// ///
@ -83,9 +84,11 @@ type FiltersWithHandlers<'a, T, E> = Vec<FilterWithHandler<'a, T, E>>;
/// // error handler that just ignores all errors (that can't ever happen). /// // error handler that just ignores all errors (that can't ever happen).
/// let mut dp = FilterDispatcher::<Infallible, _>::new(|_| async {}) /// let mut dp = FilterDispatcher::<Infallible, _>::new(|_| async {})
/// // Add a handler, which handles all messages sent to the bot. /// // Add a handler, which handles all messages sent to the bot.
/// .message_handler(true, |mes: Message| async move { /// .message_handler(true, |mes: Message| {
/// async move {
/// println!("New message: {:?}", mes); /// println!("New message: {:?}", mes);
/// Ok(()) /// Ok(())
/// }
/// }) /// })
/// // Add a handler, which handles all messages edited in a chat /// // Add a handler, which handles all messages edited in a chat
/// // with the bot. /// // with the bot.

View file

@ -39,11 +39,13 @@ pub async fn download_file_stream(
.await? .await?
.error_for_status()?; .error_for_status()?;
Ok(futures::stream::unfold(res, |mut res| async { Ok(futures::stream::unfold(res, |mut res| {
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,
} }
}
})) }))
} }

View file

@ -121,7 +121,8 @@ mod tests {
fn test_link() { fn test_link() {
assert_eq!( assert_eq!(
link("https://www.google.com/?q=foo&l=ru", "<google>"), link("https://www.google.com/?q=foo&l=ru", "<google>"),
"<a href=\"https://www.google.com/?q=foo&amp;l=ru\">&lt;google&gt;</a>", "<a href=\"https://www.google.com/?q=foo&amp;l=ru\">&lt;google&gt;\
</a>",
); );
} }