Struct nvim_utils::prelude::LuaUserDataMetatable
source · pub struct LuaUserDataMetatable<'lua>(_);
Expand description
Handle to a UserData
metatable.
Implementations§
source§impl<'lua> UserDataMetatable<'lua>
impl<'lua> UserDataMetatable<'lua>
sourcepub fn get<K, V>(&self, key: K) -> Result<V, Error>where
K: Into<MetaMethod>,
V: FromLua<'lua>,
pub fn get<K, V>(&self, key: K) -> Result<V, Error>where K: Into<MetaMethod>, V: FromLua<'lua>,
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, V>(&self, key: K, value: V) -> Result<(), Error>where
K: Into<MetaMethod>,
V: ToLua<'lua>,
pub fn set<K, V>(&self, key: K, value: V) -> Result<(), Error>where K: Into<MetaMethod>, V: ToLua<'lua>,
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§
source§impl<'lua> Clone for UserDataMetatable<'lua>
impl<'lua> Clone for UserDataMetatable<'lua>
source§fn clone(&self) -> UserDataMetatable<'lua>
fn clone(&self) -> UserDataMetatable<'lua>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more