mirror of
https://github.com/mlua-rs/mlua
synced 2026-06-08 16:05:43 +00:00
Optimize creation of userdata callbacks (registry)
This commit is contained in:
@@ -361,6 +361,14 @@ impl<'a, T> TryFrom<&'a UserDataVariant<T>> for UserDataBorrowRef<'a, T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T> UserDataBorrowRef<'a, T> {
|
||||
#[inline(always)]
|
||||
pub(crate) fn get_ref(&self) -> &'a T {
|
||||
// SAFETY: `UserDataBorrowRef` is only created when the borrow flag is set to reading.
|
||||
unsafe { self.0.get_ref() }
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct UserDataBorrowMut<'a, T>(&'a UserDataVariant<T>);
|
||||
|
||||
impl<'a, T> Drop for UserDataBorrowMut<'a, T> {
|
||||
@@ -396,6 +404,14 @@ impl<'a, T> TryFrom<&'a UserDataVariant<T>> for UserDataBorrowMut<'a, T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T> UserDataBorrowMut<'a, T> {
|
||||
#[inline(always)]
|
||||
pub(crate) fn get_mut(&mut self) -> &'a mut T {
|
||||
// SAFETY: `UserDataBorrowMut` is only created when the borrow flag is set to writing.
|
||||
unsafe { self.0.get_mut() }
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn try_value_to_userdata<T>(value: Value) -> Result<AnyUserData> {
|
||||
match value {
|
||||
|
||||
Reference in New Issue
Block a user