-
Notifications
You must be signed in to change notification settings - Fork 178
Open
Description
Example:
struct AState;
impl AState {
fn ui_logic(&mut self) -> impl WidgetView<Self> + use<> {
label("A")
}
}
struct BState;
impl BState {
fn ui_logic(&mut self) -> impl WidgetView<Self> + use<> {
label("B")
}
}
enum MyState {
A(AState),
B(BState)
}
impl MyState {
fn ui_logic(&mut self) -> impl WidgetView<Self> + use<> {
use xilem_core::one_of::Either;
match self {
Self::A(_a) => Either::A(lens(AState::ui_logic, |state: &mut Self| match state {
Self::A(a) => a,
_ => unreachable!(),
}))
Self::B(_b) => Either::B(lens(BState::ui_logic, |state: &mut Self| match state {
Self::B(b) => b,
_ => unreachable!(),
}))
}
}
}The same goes for matching Options and Results.
Metadata
Metadata
Assignees
Labels
No labels