diff --git a/CHANGELOG.md b/CHANGELOG.md index 70124a90cdaf924e3ccab7d9a744b60405056779..6e40157a8ebd0b31c1edcab146021ef8fff7833e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,8 @@ - `TupleBuffer` no longer copies data into tarantool's transaction memory pool in `TupleBuffer::from_vec_unchecked`, which previously would result in a use after free in some cases. +- `impl<_> From<tlua::PushIterError<_>> for tlua::Void` is now more general + which allows more types to be used in contexts like `tlua::Lua::set`, etc. - `tests/run_benchmarks.lua` now works again. ### Changed diff --git a/tests/src/tlua/values.rs b/tests/src/tlua/values.rs index cdceb6c3e1e94e20d8fce5dec466a83b4495ed37..1c77d1177f5c7c01a227579eab359e220e9a654b 100644 --- a/tests/src/tlua/values.rs +++ b/tests/src/tlua/values.rs @@ -995,5 +995,10 @@ pub fn tuple_as_table() { e.to_string(), "Can only push 1 or 2 values as lua table item" ); + + lua.set("test_tuple_as_table", AsTable((("nice", 69), ("list", [3, 2, 1])))); + let table: LuaTable<_> = lua.get("test_tuple_as_table").unwrap(); + assert_eq!(table.get("nice"), Some(69)); + assert_eq!(table.get("list"), Some([3, 2, 1])); } diff --git a/tlua/src/rust_tables.rs b/tlua/src/rust_tables.rs index ffa4a5a10236347b0defd8deb1f91414d16fd3fc..a8647f02df613b7a4fc8c2f119b03f83a7e1f033 100644 --- a/tlua/src/rust_tables.rs +++ b/tlua/src/rust_tables.rs @@ -105,6 +105,7 @@ where // don't add other ones! // T::Err: Void => no error possible +// NOTE: making this one generic would conflict with the below implementations. impl From<PushIterError<Void>> for Void { fn from(_: PushIterError<Void>) -> Self { unreachable!("no way to create instance of Void") @@ -112,15 +113,22 @@ impl From<PushIterError<Void>> for Void { } // T::Err: Void; (T,) => no error possible -impl From<PushIterError<TuplePushError<Void, Void>>> for Void { - fn from(_: PushIterError<TuplePushError<Void, Void>>) -> Self { +impl<T> From<PushIterError<TuplePushError<T, Void>>> for Void +where + T: Into<Void>, +{ + fn from(_: PushIterError<TuplePushError<T, Void>>) -> Self { unreachable!("no way to create instance of Void") } } -// T::Err: Void; U::Err: Void; (T, U) => no error possible -impl From<PushIterError<TuplePushError<Void, TuplePushError<Void, Void>>>> for Void { - fn from(_: PushIterError<TuplePushError<Void, TuplePushError<Void, Void>>>) -> Self { +// K::Err: Void; V::Err: Void; (K, V) => no error possible +impl<K, V> From<PushIterError<TuplePushError<K, TuplePushError<V, Void>>>> for Void +where + K: Into<Void>, + V: Into<Void>, +{ + fn from(_: PushIterError<TuplePushError<K, TuplePushError<V, Void>>>) -> Self { unreachable!("no way to create instance of Void") } }