You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that inside the ui.data() lambda I can't get_temp() anything from the IdTypeMap because the reference to it passed to the lambda apparently needs to be mutable. Why?
To Reproduce
Steps to reproduce the behavior:
Create an eframe project and plop down some widget
Inside the lambda that accepts &mut egui::Ui do
let x_id = ui.id().with("x");let x = ui.data(|d| d.get_temp::<u32>(x_id).unwrap_or_default());
error[E0596]: cannot borrow `*d` as mutable, as it is behind a `&` reference
--> [DATA EXPUNGED].rs:41:33
|
41 | let x = ui.data(|d| d.get_temp::<u32>(x_id).unwrap_or_default());
| - ^^^^^^^^^^^^^^^^^^^^^^^ `d` is a `&` reference, so the data it refers to cannot be borrowed as mutable
| |
| consider changing this binding's type to be: `&mut IdTypeMap`
Expected behavior
Since get_temp() clones the value, the IdTypeMap is not required to be mutable. Applies to all "read" methods.
Screenshots
Desktop (please complete the following information):
Describe the bug
It seems that inside the
ui.data()
lambda I can'tget_temp()
anything from theIdTypeMap
because the reference to it passed to the lambda apparently needs to be mutable. Why?To Reproduce
Steps to reproduce the behavior:
eframe
project and plop down some widget&mut egui::Ui
doExpected behavior
Since
get_temp()
clones the value, theIdTypeMap
is not required to be mutable. Applies to all "read" methods.Screenshots
Desktop (please complete the following information):
Linux 5.18.0-14parrot1-amd64 #1 SMP PREEMPT_DYNAMIC Debian 5.18.14-1parrot1 (2022-08-07) x86_64 GNU/Linux
master
(7215fdf)Additional context
Am I missing something? This seems very weird.
Possibly related:
The text was updated successfully, but these errors were encountered: