Update README

This commit is contained in:
Alex Orlenko 2019-11-05 11:51:16 +00:00
parent abff36c6c8
commit 6b9323516f
1 changed files with 11 additions and 11 deletions

View File

@ -107,19 +107,19 @@ resumed then by propagating the Lua error to Rust code.
For example:
``` rust
let lua = Lua::new();
let f = lua.create_function(|_, ()| -> LuaResult<()> {
panic!("test panic");
})?;
lua.globals().set("rust_func", f)?;
let lua = Lua::new();
let f = lua.create_function(|_, ()| -> LuaResult<()> {
panic!("test panic");
})?;
lua.globals().set("rust_func", f)?;
let _ = lua.load(r#"
local status, err = pcall(rust_func)
print(err) -- prints: test panic
error(err) -- propagate panic
"#).exec();
let _ = lua.load(r#"
local status, err = pcall(rust_func)
print(err) -- prints: test panic
error(err) -- propagate panic
"#).exec();
panic!("must be never executed")
unreachable!()
```
`mlua` should also be panic safe in another way as well, which is that any `Lua`