Skip to content

feat(tlua): now can read strict numeric types using Strict

Georgy Moshkin requested to merge feat/tlua/strict-numeric-lua-read into master

Reading regular numeric types from lua types will performs implicit coercion:

let i: i64 = lua.eval("return 3.14").unwrap();
assert_eq!(i, 3);

But now can use Strict to read strictly specified type without implicit coercions:

use tlua::Strict;
let i: Option<Strict<i64>> = lua.eval("return 3.14").ok();
assert_eq!(i, None);
let f: Option<Strict<f32>> = lua.eval("return 3.14").ok();
assert_eq!(f, Some(Strict(3.14)));

Merge request reports