Skip to content

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!{ ... });

@gbj
Copy link
Collaborator

gbj commented Jan 17, 2025

Thanks! I think this is nice.

@gbj gbj merged commit 9fd2a75 into leptos-rs:main Jan 17, 2025
74 checks passed
zakstucke pushed a commit to zakstucke/leptos that referenced this pull request Jan 21, 2025
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.

2 participants