You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Rust, T::from* and T::to* imply creating a T from another type or converting the T to another type (doesn't have to consume T).
Lua::from doesn't create a Lua object, it merely uses it to perform the conversion, producing a Value. Similarly, Lua::to doesn't convert the Lua object, it converts its argument (a Value).
I think the best way to clear this up is to remove both methods - they are merely wrappers around t.to_lua and T::from_lua respectively, which is perfectly clear.
The text was updated successfully, but these errors were encountered:
The same could be said for pack / unpack, I just find them slightly awkward to use otherwise.
I use those to / from methods constantly, mostly because I get really tired of writing T::from_lua(t, lua) instead of lua.to(t).
I think this is a symptom of the awkward names of to_lua, from_lua, to_lua_multi, and from_lua_multi. Is there possibly a better, short punchy name other than 'from' and 'to' to call these that is less confusing? Is there possibly some other API design that we can use for ToLua / FromLua / ToLuaMulti / FromLuaMulti?
This is addressed by PR #32, but I'm not 100% sure I love the result. Now the term "packing" refers to taking any value and packaging it in the universal Any type, and unpacking refers to the opposite, and there's now pack_multi and unpack_multi.
In Rust,
T::from*
andT::to*
imply creating aT
from another type or converting theT
to another type (doesn't have to consumeT
).Lua::from
doesn't create aLua
object, it merely uses it to perform the conversion, producing aValue
. Similarly,Lua::to
doesn't convert theLua
object, it converts its argument (aValue
).I think the best way to clear this up is to remove both methods - they are merely wrappers around
t.to_lua
andT::from_lua
respectively, which is perfectly clear.The text was updated successfully, but these errors were encountered: