Conversation
|
I think this is another instance of the bug in rustc (or something related at least): #xilem > ✔ Writing a styled button helper It does compile as expected with the new trait-solver (i.e. Might be worth to open a minimal reproduction in rust for this issue in the old solver, but then again, it seems to be fixed in the new solver, so I don't think there's gonna be action on it anyway (at least if the new solver will be stabilized soon)... |
Thanks, that's good to know! I wouldn't have thought of that.
I'll keep an eye on the process for a while, and if it looks like the feature will be stabilized this year, I'll be happy 😉 |
While the trait solver in particular is more or less the top priority of the Rust maintainers and I have good hopes it's stabilized before the end of the year, as a general policy I would rather not make any assumption about future Rust improvements, because black swans happen and they can delay improvements for years. Anyway, I'll look into that bug, hopefully tomorrow. |
|
(Quick ping to say, I haven't forgotten about this, but I've been sick for a week.) |
Oh dear, I hope you're feeling better now? |
Did your code compile before you added the Either way, after trying for a while to make this code compile, I think the takeaway is that we urgently need to get rid of the |
yes!
I just tried it with the current master (416c156) with the same behavior.
Good to know. Is there anything I can help? |
Depends on how deep you want to dive :) Also related: #xilem > Adapting non-trivial State I still think it's worth it to explore: #xilem > Removing App State, but this is a fairly radical change with a lot of unknowns. |
Interesting. I'll take a look here and there. |
Can you push a compiling commit then? (With the |
|
Welp, by now I've spent more than five hours looking at the code and I can't figure out how to fix the general problem except "remove the ViewArgument trait". On the shorter term, you probably want to use the trick mentioned in the Zulip thread Philipp linked; in our case that means specifying html::div((
"Some content ...",
html::button::<Edit<AppState>, _, _>("click").on_click(|s: &mut AppState, _| {
s.clicks += 1;
}),
)),Doing that makes the code compile on my end. |
😮
Okay, and that would have a lot of consequences, right?
Well, it's not the most beautiful code, but it could be much worse 😉 Thank you for investing your time! |
Well, as Philipp said, we weren't using it that much anyway. |
Okay, I'll try that and see what the code base would look like if there were no more |
Motivated by #1638 (comment) this PR basically reverts #1444.
|
As I said here, I have been using ViewArgument to pass only relevant parts of app state to children views. While working on the aforementioned project I have also been bitten by next solver not being available (I think?). But a little judicious boxing (a total of 4 times in ~350 LOC) of the view tree and callbacks solved the problem for me. Anyway, at the time this ViewArgument "experiment" landed, I was skeptical of its benefits and annoyed with its cumbersome Arg/Edit/Read wrapping usage. But now I do think that the design has its merit. Alas, it is gone while I have been away, having fun using it. 😢 |
What exactly do you mean? |
|
This is the place where I extract only the relevant part of app state for the child view. I guess this can be done using an Adapt view too, have to see. |
|
I just remembered that we've removed Adapt view earlier. I see no option other than index-unwrap in the child. |
|
Sorry, I still don't understand the problem. What do you mean by
Are you talking about this line? let (idx, reader_state) = state.reader.as_mut().unwrap();Your pub reader: Option<(usize, ScrollingReader)>So you either I assume you mean something else, but please specify exactly what you mean! |
|
With And you might read the whole file I linked earlier. If you have any suggestions how can I better structure the code, I'd be very grateful. Thanks! |
|
Okay, I've gotten around to update Xilem for my project and here is the diff. Notice that:
An alternative would have been to have And the aforementioned first problem is also error-prone, as it is possible to forget to update the local state in the event handler. But all that said, I think I was one of the first to be bitten by the Thanks for your patience! |
I just now figured out that a local copy of the font size in the view function would do the trick. No need to duplicate data in |
I am trying to demonstrate how to build components that are generic,
but as soon as I define the event handler
I get this error message that I don't understand:
Can anyone help me?