Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: either_or combinator #3417

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

geovie
Copy link
Contributor

@geovie geovie commented Dec 28, 2024

This is an idea that came out of this feature request.

It adds an EitherOr trait providing a either_or method which can be used to "map" over bool, Option and Result types in a similar manner as e.g. Option.map_or_else.

With this there is yet another way to remove the need for to_any or to manually specify the Either::Left/Right:
e.g.

if let Some(key) = phantom_wallet_adapter.get().public_key() {
  view!{ ... }.into_any()
} else {
  view!{ ... }.into_any()
}

could be then written as

phantom_wallet_adapter.get().public_key().either_or(|key| view!{ ... }, |_| view!{ ... });

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.

1 participant