summaryrefslogtreecommitdiff
path: root/src/userdata.rs
diff options
context:
space:
mode:
authorAlex Orlenko <zxteam@protonmail.com>2021-06-03 18:43:29 +0100
committerAlex Orlenko <zxteam@protonmail.com>2021-06-03 18:43:29 +0100
commit64faebf4079e9e786e81c440fc8e20ec9939b2ee (patch)
treee5efcf3bed7d055fd95d15517e8db2f0eb45de41 /src/userdata.rs
parenta944f4ad6f1d3ae379abf53bc846e6d7ee360f83 (diff)
downloadmlua-64faebf4079e9e786e81c440fc8e20ec9939b2ee.zip
Add `__ipairs` metamethod (again) for Lua 5.2 only
Diffstat (limited to 'src/userdata.rs')
-rw-r--r--src/userdata.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/userdata.rs b/src/userdata.rs
index b9bb302..1decf1a 100644
--- a/src/userdata.rs
+++ b/src/userdata.rs
@@ -104,6 +104,15 @@ pub enum MetaMethod {
/// Requires `feature = "lua54/lua53/lua52"`
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52", doc))]
Pairs,
+ /// The `__ipairs` metamethod.
+ ///
+ /// This is not an operator, but it will be called by the built-in [`ipairs`] function.
+ ///
+ /// Requires `feature = "lua52"`
+ ///
+ /// [`ipairs`]: https://www.lua.org/manual/5.2/manual.html#pdf-ipairs
+ #[cfg(any(feature = "lua52", doc))]
+ IPairs,
/// The `__close` metamethod.
///
/// Executed when a variable, that marked as to-be-closed, goes out of scope.
@@ -181,6 +190,8 @@ impl MetaMethod {
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
MetaMethod::Pairs => "__pairs",
+ #[cfg(feature = "lua52")]
+ MetaMethod::IPairs => "__ipairs",
#[cfg(feature = "lua54")]
MetaMethod::Close => "__close",
@@ -241,6 +252,8 @@ impl From<StdString> for MetaMethod {
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
"__pairs" => MetaMethod::Pairs,
+ #[cfg(feature = "lua52")]
+ "__ipairs" => MetaMethod::IPairs,
#[cfg(feature = "lua54")]
"__close" => MetaMethod::Close,