Struct mlua::UserDataMetatable
source · [−]pub struct UserDataMetatable<'lua>(_);
Expand description
Handle to a UserData
metatable.
Implementations
sourceimpl<'lua> UserDataMetatable<'lua>
impl<'lua> UserDataMetatable<'lua>
sourcepub fn get<K: Into<MetaMethod>, V: FromLua<'lua>>(&self, key: K) -> Result<V>
pub fn get<K: Into<MetaMethod>, V: FromLua<'lua>>(&self, key: K) -> Result<V>
Gets the value associated to key
from the metatable.
If no value is associated to key
, returns the Nil
value.
Access to restricted metamethods such as __gc
or __metatable
will cause an error.
sourcepub fn set<K: Into<MetaMethod>, V: ToLua<'lua>>(
&self,
key: K,
value: V
) -> Result<()>
pub fn set<K: Into<MetaMethod>, V: ToLua<'lua>>(
&self,
key: K,
value: V
) -> Result<()>
Sets a key-value pair in the metatable.
If the value is Nil
, this will effectively remove the key
.
Access to restricted metamethods such as __gc
or __metatable
will cause an error.
Setting __index
or __newindex
metamethods is also restricted because their values are cached
for mlua
internal usage.
Trait Implementations
sourceimpl<'lua> Clone for UserDataMetatable<'lua>
impl<'lua> Clone for UserDataMetatable<'lua>
sourcefn clone(&self) -> UserDataMetatable<'lua>
fn clone(&self) -> UserDataMetatable<'lua>
Returns a copy of the value. Read more
1.0.0 · sourceconst fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations
impl<'lua> !RefUnwindSafe for UserDataMetatable<'lua>
impl<'lua> !Send for UserDataMetatable<'lua>
impl<'lua> !Sync for UserDataMetatable<'lua>
impl<'lua> Unpin for UserDataMetatable<'lua>
impl<'lua> !UnwindSafe for UserDataMetatable<'lua>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more