pub struct UserDataMetatable(/* private fields */);
Expand description
Handle to a UserData
metatable.
Implementations§
Source§impl UserDataMetatable
impl UserDataMetatable
Sourcepub fn get<V: FromLua>(&self, key: impl AsRef<str>) -> Result<V>
pub fn get<V: FromLua>(&self, key: impl AsRef<str>) -> 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(&self, key: impl AsRef<str>, value: impl IntoLua) -> Result<()>
pub fn set(&self, key: impl AsRef<str>, value: impl IntoLua) -> 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§
Source§impl Clone for UserDataMetatable
impl Clone for UserDataMetatable
Source§fn clone(&self) -> UserDataMetatable
fn clone(&self) -> UserDataMetatable
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 Freeze for UserDataMetatable
impl !RefUnwindSafe for UserDataMetatable
impl Send for UserDataMetatable
impl Sync for UserDataMetatable
impl Unpin for UserDataMetatable
impl !UnwindSafe for UserDataMetatable
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