Skip to content

Add fallible handlers try_filter, try_map, try_filter_map - #39

Open
YouKnow-sys wants to merge 1 commit into
teloxide:masterfrom
YouKnow-sys:fallible_handlers
Open

Add fallible handlers try_filter, try_map, try_filter_map#39
YouKnow-sys wants to merge 1 commit 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`).
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

1 participant