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,10 +31,11 @@ type FiltersWithHandlers<'a, T, E> = Vec<FilterWithHandler<'a, T, E>>;
/// use std::convert::Infallible;
/// use teloxide::{dispatching::FilterDispatcher, RequestError};
///
/// let _ =
/// FilterDispatcher::new(|err: Either<RequestError, Infallible>| async {
/// let _ = FilterDispatcher::new(|err: Either<RequestError, Infallible>| {
/// async {
/// dbg!(err);
/// });
/// }
/// });
/// ```
///
/// Or you can do it even simpler by providing the built-in error handler
@ -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).
/// let mut dp = FilterDispatcher::<Infallible, _>::new(|_| async {})
/// // Add a handler, which handles all messages sent to the bot.
/// .message_handler(true, |mes: Message| async move {
/// println!("New message: {:?}", mes);
/// Ok(())
/// .message_handler(true, |mes: Message| {
/// async move {
/// println!("New message: {:?}", mes);
/// Ok(())
/// }
/// })
/// // Add a handler, which handles all messages edited in a chat
/// // with the bot.

View file

@ -39,11 +39,13 @@ pub async fn download_file_stream(
.await?
.error_for_status()?;
Ok(futures::stream::unfold(res, |mut res| async {
match res.chunk().await {
Err(err) => Some((Err(err), res)),
Ok(Some(c)) => Some((Ok(c), res)),
Ok(None) => None,
Ok(futures::stream::unfold(res, |mut res| {
async {
match res.chunk().await {
Err(err) => Some((Err(err), res)),
Ok(Some(c)) => Some((Ok(c), res)),
Ok(None) => None,
}
}
}))
}

View file

@ -121,7 +121,8 @@ mod tests {
fn test_link() {
assert_eq!(
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>",
);
}