~ioiojo/fennel-searcher-rs

Require Fennel modules by name
update license year to 2023
update dependencies
enforce at least one version of fennel be chosen

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~ioiojo/fennel-searcher-rs
read/write
git@git.sr.ht:~ioiojo/fennel-searcher-rs

You can also use your local clone with git send-email.

#fennel-searcher

Require Fennel modules by name at runtime.

#Synopsis

#In your Cargo manifest:

If you wish to accept the default Fennel release version provided by fennel-src:

[dependencies]
fennel-searcher = "*"

If you wish to specify a Fennel release version:

# basic
[dependencies]
fennel-searcher = { version = "*", default-features = false, features = ["fennel100"] }
# advanced
[features]
default = ["fennel100"]
fennel100 = ["fennel-searcher/fennel100"]

[dependencies]
fennel-searcher = { version = "*", default-features = false }

#Code

use fennel_searcher::AddSearcherFnl;
use rlua::Lua;
use std::borrow::Cow;
use std::collections::HashMap;
use std::path::PathBuf;

fn main() {
    let lime = Cow::from("lime/color");
    let color = PathBuf::new()
        .join(env::var("CARGO_MANIFEST_DIR").unwrap())
        .join("testcrate")
        .join("lime")
        .join("color.fnl");
    let mut map = HashMap::new();
    map.insert(lime, color);

    let lua = Lua::new();

    let color = lua.context::<_, String>(|lua_ctx| {
        lua_ctx.add_path_searcher_fnl(lime).unwrap();
        lua_ctx
            .load(r#"return require("lime/color")"#)
            .eval()
            .unwrap()
    });

    assert_eq!(&color, "green");
}

#License

Licensed under either of

at your option.

#Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Do not follow this link