Imagine this fairly basic situation: you have a button object. When clicked, it triggers a closure (callback). And that closure needs to change the button's text to e.g. "Clicked!".
To do this in Rust, the closure needs a mutable reference to the button. However, the GUI event loop also needs a reference to the button to draw it on the screen. In Rust, you can have many immutable references, __or__ exactly one mutable reference, but never both at the same time. Since the GUI framework holds the button, it won't let your closure mutably borrow it at the same time.
Imagine this fairly basic situation: you have a button object. When clicked, it triggers a closure (callback). And that closure needs to change the button's text to e.g. "Clicked!".
To do this in Rust, the closure needs a mutable reference to the button. However, the GUI event loop also needs a reference to the button to draw it on the screen. In Rust, you can have many immutable references, __or__ exactly one mutable reference, but never both at the same time. Since the GUI framework holds the button, it won't let your closure mutably borrow it at the same time.