-
Notifications
You must be signed in to change notification settings - Fork 256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Documentation about borrow types #1916
Comments
By default IMHO; try to add IIRC this was originally non-opaque, but later it gives problems on some scenarios and thus the default is flipped and it looks like this... |
Thanks! But it doesn't seem to work:
my struct is
Probably this was where the problem with non-opaque borrowed fields started? |
Hmm, it looks like borrowed opaque types are not supported (at least yet). To work on it, maybe we can first discuss - what code should it generate? Unsafe code can definitely handle it, but I would like to have as little unsafe code as possible, surely ;) |
Yes, I agree - I would not like unsafe code as well. |
Rethinking this, I guess another way may be: struct MyModel {
items : Vec<Arc<Field>>
}
struct MyViewModel {
my_items : Vec<Arc<Field>>,
not_my_items : Vec<Arc<Field>>,
total_item_count : u64
} i.e. use |
@fzyzcjy thanks, that is a great idea! I currently implemented it with each (complex) item having a distinct ID, and sharing a lookup table of these between dart and rust. But an Arc sounds like a better, more direct approach. Will try that :) |
I am not totally sure, but I assume that a struct with borrowed fields is
auto opaque
?If so, can this be stated better in the documentation, for others?
My use case is having a viewModel, but defined in Rust. Thus it needs to be read by flutter, so I can't use an opaque type. But being a viewModel, I want to use borrowed values from the Model ... so the only option left is cloning the model's fields on each access ... or implementing the view logic in Flutter. So either the performance is suboptimal, or the logic might be repeated for different UIs (Flutter, cli, ...).
For example, a model like
could have the viewModel
This is all very theoretical - as the performance hit might be not noticeable and I might never have a second UI, as Flutter covers all platforms.
But back to my request: It would be good to document this more clear if I understood it correctly.
The text was updated successfully, but these errors were encountered: