Struct rlua::UserDataMetatable
source · pub struct UserDataMetatable<'lua>(/* private fields */);
Expand description
Handle to a UserData
metatable.
Implementations§
source§impl<'lua> UserDataMetatable<'lua>
impl<'lua> UserDataMetatable<'lua>
sourcepub fn get<V>(&self, key: impl AsRef<str>) -> Result<V, Error>where
V: FromLua<'lua>,
pub fn get<V>(&self, key: impl AsRef<str>) -> Result<V, Error>where
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<V>(&self, key: impl AsRef<str>, value: V) -> Result<(), Error>where
V: IntoLua<'lua>,
pub fn set<V>(&self, key: impl AsRef<str>, value: V) -> Result<(), Error>where
V: IntoLua<'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 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§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more