diff options
author | Alex Orlenko <zxteam@protonmail.com> | 2020-01-25 19:41:02 +0000 |
---|---|---|
committer | Alex Orlenko <zxteam@protonmail.com> | 2020-01-25 20:47:36 +0000 |
commit | e4dc773aa3130d70c76dcfabc2018b8ff700ec2c (patch) | |
tree | 9018865a600914b4580a66489ef35d5d1581cd2c | |
parent | 07fc4642ae9d6c9a33ae32c6a3f6bfc9fae815a8 (diff) | |
download | mlua-e4dc773aa3130d70c76dcfabc2018b8ff700ec2c.zip |
Remove `__ipairs` metamethod deprecated in lua 5.3 and not available by default
-rw-r--r-- | src/userdata.rs | 7 | ||||
-rw-r--r-- | tests/userdata.rs | 12 |
2 files changed, 6 insertions, 13 deletions
diff --git a/src/userdata.rs b/src/userdata.rs index 32817b6..ed5db3d 100644 --- a/src/userdata.rs +++ b/src/userdata.rs @@ -77,11 +77,6 @@ pub enum 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 { @@ -119,8 +114,6 @@ impl MetaMethod { MetaMethod::ToString => b"__tostring", #[cfg(any(feature = "lua53", feature = "lua52"))] MetaMethod::Pairs => b"__pairs", - #[cfg(any(feature = "lua53", feature = "lua52"))] - MetaMethod::IPairs => b"__ipairs", } } } diff --git a/tests/userdata.rs b/tests/userdata.rs index 19a8b95..64919cf 100644 --- a/tests/userdata.rs +++ b/tests/userdata.rs @@ -96,7 +96,7 @@ fn test_metamethods() -> Result<()> { } }); #[cfg(any(feature = "lua53", feature = "lua52"))] - methods.add_meta_method(MetaMethod::IPairs, |lua, data, ()| { + methods.add_meta_method(MetaMethod::Pairs, |lua, data, ()| { use std::iter::FromIterator; let stateless_iter = lua.create_function(|_, (data, i): (MyUserData, i64)| { let i = i + 1; @@ -121,12 +121,12 @@ fn test_metamethods() -> Result<()> { ); #[cfg(any(feature = "lua53", feature = "lua52"))] - let ipairs_it = { + let pairs_it = { lua.load( r#" - function ipairs_it() + function pairs_it() local r = 0 - for i, v in ipairs(userdata1) do + for i, v in pairs(userdata1) do r = r + v end return r @@ -134,14 +134,14 @@ fn test_metamethods() -> Result<()> { "#, ) .exec()?; - globals.get::<_, Function>("ipairs_it")? + globals.get::<_, Function>("pairs_it")? }; assert_eq!(lua.load("userdata1 - userdata2").eval::<MyUserData>()?.0, 4); assert_eq!(lua.load("userdata1:get()").eval::<i64>()?, 7); assert_eq!(lua.load("userdata2.inner").eval::<i64>()?, 3); #[cfg(any(feature = "lua53", feature = "lua52"))] - assert_eq!(ipairs_it.call::<_, i64>(())?, 28); + assert_eq!(pairs_it.call::<_, i64>(())?, 28); assert!(lua.load("userdata2.nonexist_field").eval::<()>().is_err()); let userdata2: Value = globals.get("userdata2")?; |