trust + fix redraw bug
This commit is contained in:
@@ -56,11 +56,6 @@ impl<State, W: ?Sized> WidgetHandle<State, W> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_any(&self) -> &WidgetHandle<State, dyn Widget<State>> {
|
||||
// SAFETY: self is repr(C) and generic only used for phantom data
|
||||
unsafe { std::mem::transmute(self) }
|
||||
}
|
||||
|
||||
pub fn id(&self) -> WidgetId {
|
||||
self.id
|
||||
}
|
||||
|
||||
@@ -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