trust + fix redraw bug
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
IdLike, Widget, WidgetData, WidgetId,
|
||||
util::{DynBorrower, HashSet, SlotVec},
|
||||
util::{DynBorrower, HashSet, SlotVec, forget_mut, to_mut},
|
||||
};
|
||||
|
||||
pub struct Widgets<State> {
|
||||
@@ -36,12 +36,7 @@ impl<State: 'static> Widgets<State> {
|
||||
pub(crate) fn get_dyn_dynamic<'a>(&self, id: WidgetId) -> WidgetWrapper<'a, State> {
|
||||
// SAFETY: must guarantee no other mutable references to this widget exist
|
||||
// done through the borrow variable
|
||||
#[allow(mutable_transmutes)]
|
||||
let data = unsafe {
|
||||
std::mem::transmute::<&WidgetData<State>, &mut WidgetData<State>>(
|
||||
self.vec.get(id).unwrap(),
|
||||
)
|
||||
};
|
||||
let data = unsafe { forget_mut(to_mut(self.vec.get(id).unwrap())) };
|
||||
if data.borrowed {
|
||||
panic!("tried to mutably borrow the same widget twice");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user