Use Pin<&Self> for Property::get

This commit is contained in:
Olivier Goffart 2020-06-26 13:18:04 +02:00
parent 0029921f1a
commit 2d22bac451
5 changed files with 108 additions and 74 deletions

View file

@ -112,15 +112,15 @@ Hello := Rectangle {
fn main() {
let mut app = Hello::default();
app.plus_clicked.set_handler(|context, ()| {
let app = context.get_component::<Hello>().unwrap();
app.counter.set(app.counter.get(context) + 1);
let counter = Hello::field_offsets().counter.apply_pin(app);
counter.set(counter.get(context) + 1);
});
app.minus_clicked.set_handler(|context, ()| {
let app = context.get_component::<Hello>().unwrap();
app.counter.set(app.counter.get(context) - 1);
let counter = Hello::field_offsets().counter.apply_pin(app);
counter.set(counter.get(context) - 1);
});
app.run();
}