#![allow(clippy::inline_always)] use std::cell::Ref; use mlua::prelude::*; use num::cast::AsPrimitive; use super::NativeData; // Cast T as U #[inline(always)] pub fn native_num_cast( from: &Ref, into: &Ref, ) -> LuaResult<()> where T: AsPrimitive, U: 'static + Copy, { let from_ptr = unsafe { from.get_pointer().cast::() }; let into_ptr = unsafe { into.get_pointer().cast::() }; unsafe { *into_ptr = (*from_ptr).as_(); } Ok(()) }