Closed jack1243star closed 7 years ago
If you write for example this:
let _ = lua.execute::<String>(r"return '\xff\xfe\xff\xfe'").unwrap();
Then the unwrap
will panic, but it's the job of the library user to handle the fact that the string may not be convertible to a Rust String.
However in your example we're talking about AnyLuaValue
, and I agree that reading a AnyLuaValue
should never panic (as its role is to accept any possible Lua type).
When it comes to representing strings, the problem with representing strings as Vec<u8>
is that a Lua array of numbers may also be represented as a Vec<u8>
.
We probably need some sort of custom type (eg. LuaString
) that holds a Vec<u8>
internally.
As Lua strings are plain bytes, it cannot be represented using Rust strings. The code:
results in:
Lua strings should be represented as vectors of
u8
.