summaryrefslogtreecommitdiff
path: root/src/lua.rs
diff options
context:
space:
mode:
authorAlex Orlenko <zxteam@protonmail.com>2022-12-24 19:16:58 +0000
committerAlex Orlenko <zxteam@protonmail.com>2022-12-24 19:16:58 +0000
commitd67332a3ac7245b8e169eec9ccdc970315b86397 (patch)
tree7d3de67488f0bfb324dcff1db102890ec401e6c8 /src/lua.rs
parent22c6e9a7e79675021a9479b5f570fcc60a40c641 (diff)
downloadmlua-d67332a3ac7245b8e169eec9ccdc970315b86397.zip
Refactor `userdata::MetaMethod`.
Take `impl AsRef<str>` as name of metamethod (instead of `Into<MetaMethod>`) in UserDataMethods/UserDataFields. Change position of generic args in userdata.
Diffstat (limited to 'src/lua.rs')
-rw-r--r--src/lua.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/lua.rs b/src/lua.rs
index 5acab41..2b0cdf4 100644
--- a/src/lua.rs
+++ b/src/lua.rs
@@ -29,7 +29,7 @@ use crate::types::{
Callback, CallbackUpvalue, DestructedUserdata, Integer, LightUserData, LuaRef, MaybeSend,
Number, RegistryKey,
};
-use crate::userdata::{AnyUserData, UserData, UserDataCell};
+use crate::userdata::{AnyUserData, MetaMethod, UserData, UserDataCell};
use crate::userdata_impl::{StaticUserDataFields, StaticUserDataMethods, UserDataProxy};
use crate::util::{
self, assert_stack, callback_error, check_stack, get_destructed_userdata_metatable,
@@ -2515,16 +2515,16 @@ impl Lua {
push_table(state, 0, metatable_nrec as c_int, true)?;
for (k, m) in methods.meta_methods {
self.push_value(Value::Function(self.create_callback(m)?))?;
- rawset_field(state, -2, k.validate()?.name())?;
+ rawset_field(state, -2, MetaMethod::validate(&k)?)?;
}
#[cfg(feature = "async")]
for (k, m) in methods.async_meta_methods {
self.push_value(Value::Function(self.create_async_callback(m)?))?;
- rawset_field(state, -2, k.validate()?.name())?;
+ rawset_field(state, -2, MetaMethod::validate(&k)?)?;
}
for (k, f) in fields.meta_fields {
self.push_value(f(self)?)?;
- rawset_field(state, -2, k.validate()?.name())?;
+ rawset_field(state, -2, MetaMethod::validate(&k)?)?;
}
let metatable_index = ffi::lua_absindex(state, -1);