init
This commit is contained in:
40
README.md
Normal file
40
README.md
Normal file
@@ -0,0 +1,40 @@
|
||||
# rlua-searcher
|
||||
|
||||
`require` Lua modules by name
|
||||
|
||||
## Description
|
||||
|
||||
Encode a Lua module as a `HashMap` of Lua strings indexed by module
|
||||
name. In an `rlua::Context`, pass the `HashMap` to `add_searcher()`,
|
||||
and `require` the module.
|
||||
|
||||
## Synopsis
|
||||
|
||||
```rust
|
||||
use rlua_searcher::AddSearcher;
|
||||
|
||||
fn main() {
|
||||
let lume = read_lume_to_string();
|
||||
let name = "lume";
|
||||
let map = HashMap::new<String, String>();
|
||||
map.insert(name, lume);
|
||||
|
||||
let lua = Lua::new;
|
||||
|
||||
let hello = lua.context::<_, rlua::Result<_>>(|lua_ctx| {
|
||||
lua_ctx.add_searcher(map)?;
|
||||
Ok(lua_ctx.load(r#"require("lume")"#).eval()?)
|
||||
}).unwrap();
|
||||
|
||||
// prints "hello lume"
|
||||
println!("{}", hello);
|
||||
}
|
||||
|
||||
fn read_lume_to_string() -> String {
|
||||
r#"return "hello lume""#.to_string()
|
||||
}
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
Reference in New Issue
Block a user