-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
bugSomething is brokenSomething is broken
Description
Describe the bug
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
eframeproject and plop down some widget - Inside the lambda that accepts
&mut egui::Uido
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):
- OS:
Linux 5.18.0-14parrot1-amd64 #1 SMP PREEMPT_DYNAMIC Debian 5.18.14-1parrot1 (2022-08-07) x86_64 GNU/Linux - Browser
- Version
master(7215fdf)
Additional context
Am I missing something? This seems very weird.
Possibly related:
juancampa
Metadata
Metadata
Assignees
Labels
bugSomething is brokenSomething is broken