use std::cell::Ref; use mlua::prelude::*; use num::cast::AsPrimitive; use super::FfiData; #[inline] pub fn num_cast( from: &Ref, into: &Ref, from_offset: isize, into_offset: isize, ) -> LuaResult<()> where From: AsPrimitive, Into: 'static + Copy, { let from_ptr = unsafe { from.get_inner_pointer() .byte_offset(from_offset) .cast::() }; let into_ptr = unsafe { into.get_inner_pointer() .byte_offset(into_offset) .cast::() }; unsafe { *into_ptr = (*from_ptr).as_(); } Ok(()) }