Implement Data for Vec<Data>#911
Conversation
|
so long-term we don't want data for vec; we want data-aware collection types that are cheap to clone; and currently, if you're using a vec for data, it should probably be in an |
|
Should this be reverted? 🤔 |
|
Well, I think it is nice for ergonomics, as But some good collection types, maybe similar to the Thus I'm not to happy about this change as it pretty much will have to be reverted at some point. *Mostly for people new to druid |
|
Somewhat tangential, but I'm also wondering under what scenario the data goes on multiple threads that it needs an |
|
Yes, I think there is a note somewhere about the possibility of using |
|
After giving it some further thought, even if the underlying platform is single-threaded, druid could potentially do its own event handling in a fan-out way. Global events could be ran on a separate thread per window. Even a single window could split up the widget tree, running the event on half of the tree on one thread and the other half on another. It's not a simple change though and it's an open question how big a widget tree would have to be for multi-threaded work to be faster. This deserves its seperate topic, probably on zulip to start with. |
|
Yea, the choice of My gut feeling is that this should be reverted, but maybe also that we should speed up work on adding some immutable collection types; we've also had performance issues with people using medium term I'd like to discourage use of |
|
Looking at source, it seems like the |
|
I think some notes in the docs would be good, as people will instinctively use |
|
Thanks for the discussion, I understand now why I should avoid direct use of Vec. I'll update my code to use a clone-friendly data structure. Feel free to revert. |
|
@chris-zen Thanks for actually lighting the fire to get us to bring in some druid-appropriate collections. ;) |
This PR implements the
Datatrait for aVec<T> where T: Data, which solves the following case without having to use#[data(same_fn = "PartialEq::eq")]: