summaryrefslogtreecommitdiff
path: root/src/userdata.rs
diff options
context:
space:
mode:
authorAlex Orlenko <zxteam@protonmail.com>2019-11-30 00:52:31 +0000
committerAlex Orlenko <zxteam@protonmail.com>2019-11-30 00:58:42 +0000
commit143c3a81a7a648c1e7036190a8d3d0c656bd5c9f (patch)
tree95695f0cc597204cc32bcbc08319c10b53160648 /src/userdata.rs
parentfd17a01456452ce98fce41e257da9528ca9420a5 (diff)
downloadmlua-143c3a81a7a648c1e7036190a8d3d0c656bd5c9f.zip
Add pair and ipair metamethods support (lua 5.2/5.3 only)
Diffstat (limited to 'src/userdata.rs')
-rw-r--r--src/userdata.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/userdata.rs b/src/userdata.rs
index 18da3b4..8177ad9 100644
--- a/src/userdata.rs
+++ b/src/userdata.rs
@@ -70,6 +70,16 @@ pub enum MetaMethod {
///
/// This is not an operator, but will be called by methods such as `tostring` and `print`.
ToString,
+ #[cfg(any(feature = "lua53", feature = "lua52"))]
+ /// The `__pairs` metamethod.
+ ///
+ /// This is not an operator, but it will be called by the built-in `pairs` function.
+ Pairs,
+ #[cfg(any(feature = "lua53", feature = "lua52"))]
+ /// The `__ipairs` metamethod.
+ ///
+ /// This is not an operator, but it will be called by the built-in `ipairs` function.
+ IPairs,
}
impl MetaMethod {
@@ -105,6 +115,10 @@ impl MetaMethod {
MetaMethod::NewIndex => b"__newindex",
MetaMethod::Call => b"__call",
MetaMethod::ToString => b"__tostring",
+ #[cfg(any(feature = "lua53", feature = "lua52"))]
+ MetaMethod::Pairs => b"__pairs",
+ #[cfg(any(feature = "lua53", feature = "lua52"))]
+ MetaMethod::IPairs => b"__ipairs",
}
}
}