diff --git a/src/experimental/scene.rs b/src/experimental/scene.rs index bf3e34a2..ef99f5d5 100644 --- a/src/experimental/scene.rs +++ b/src/experimental/scene.rs @@ -285,21 +285,11 @@ impl Cell { capabilities: vec![], used, permanent: false, - ready: unsafe { - std::mem::transmute(&(Node::ready as fn(RefMut)) as *const fn(RefMut)) - }, - update: unsafe { - std::mem::transmute(&(Node::update as fn(RefMut)) as *const fn(RefMut)) - }, - fixed_update: unsafe { - std::mem::transmute(&(Node::fixed_update as fn(RefMut)) as *const fn(RefMut)) - }, - draw: unsafe { - std::mem::transmute(&(Node::draw as fn(RefMut)) as *const fn(RefMut)) - }, - virtual_drop: unsafe { - std::mem::transmute(&(virtual_drop:: as fn(*mut ())) as *const fn(*mut ())) - }, + ready: (&(Node::ready as fn(RefMut)) as *const fn(RefMut)).cast(), + update: (&(Node::update as fn(RefMut)) as *const fn(RefMut)).cast(), + fixed_update: (&(Node::fixed_update as fn(RefMut)) as *const fn(RefMut)).cast(), + draw: (&(Node::draw as fn(RefMut)) as *const fn(RefMut)).cast(), + virtual_drop: &(virtual_drop:: as fn(*mut ())) as *const fn(*mut ()), data_len: std::mem::size_of::(), initialized: false, } @@ -312,19 +302,11 @@ impl Cell { let (_, vtable) = unsafe { std::mem::transmute::<_, (*mut (), *mut ())>(trait_obj) }; self.vtable = vtable; - self.ready = - unsafe { std::mem::transmute(&(Node::ready as fn(RefMut)) as *const fn(RefMut)) }; - self.update = unsafe { - std::mem::transmute(&(Node::update as fn(RefMut)) as *const fn(RefMut)) - }; - self.fixed_update = unsafe { - std::mem::transmute(&(Node::fixed_update as fn(RefMut)) as *const fn(RefMut)) - }; - self.draw = - unsafe { std::mem::transmute(&(Node::draw as fn(RefMut)) as *const fn(RefMut)) }; - self.virtual_drop = unsafe { - std::mem::transmute(&(virtual_drop:: as fn(*mut ())) as *const fn(*mut ())) - }; + self.ready = (&(Node::ready as fn(RefMut)) as *const fn(RefMut)).cast(); + self.update = (&(Node::update as fn(RefMut)) as *const fn(RefMut)).cast(); + self.fixed_update = (&(Node::fixed_update as fn(RefMut)) as *const fn(RefMut)).cast(); + self.draw = (&(Node::draw as fn(RefMut)) as *const fn(RefMut)).cast(); + self.virtual_drop = &(virtual_drop:: as fn(*mut ())) as *const fn(*mut ()); unsafe { std::ptr::copy_nonoverlapping::(&data as *const _ as *mut _, self.data as *mut _, 1);