Skip to content

Add fallible handlers try_filter, try_map, try_filter_map - #39

Merged
hirrolot merged 3 commits into
teloxide:masterfrom
YouKnow-sys:fallible_handlers
Aug 20, 2026
Merged

Add fallible handlers try_filter, try_map, try_filter_map#39
hirrolot merged 3 commits into
teloxide:masterfrom
YouKnow-sys:fallible_handlers

Conversation

@YouKnow-sys

@YouKnow-sys YouKnow-sys commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Mirrors filter/map/filter_map, but the closure returns Result. On
Err it short-circuits the whole chain with ControlFlow::Break; symmetric
to how endpoint breaks with a value, and unlike Ok(false)/None it does
not fall through to sibling branches.

Requires the handler Output to implement a new Fallible trait
(blanket-impl'd for Result<T, E>), used to build the Err half of the output.

Closes #26, and closes #32

Each has an `_async` variant and short-circuits the handler chain with
an error on `Err` (requires `Output: Fallible`, blanket-impl'd for
`Result`).
@hirrolot
hirrolot self-requested a review August 20, 2026 12:48
Comment thread README.md Outdated
Comment thread CHANGELOG.md Outdated
@hirrolot
hirrolot self-requested a review August 20, 2026 13:00

@hirrolot hirrolot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, @YouKnow-sys!

@hirrolot
hirrolot merged commit 004c5e0 into teloxide:master Aug 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Run a handler for all messages, then another only for commands add fallible variant to filter and map

2 participants