~ioiojo/fennel-compile-rs

Compile Fennel source code to Lua
update license year to 2023
update rlua-searcher dependency
update fennel-src dep

refs

master
browse  log 

clone

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

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

#fennel-compile

Compile Fennel source code to Lua.

#Description

Adds Fennel to rlua::Context via fennel-src crate.

#Synopsis

#In your Cargo manifest:

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

[dependencies]
fennel-compile = "*"

If you wish to specify a Fennel release version:

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

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

#Code

use fennel_compile::{Compile, Mount, Result};
use rlua::Lua;

fn main() {
    let lua = Lua::new();

    let got = lua
        .context::<_, Result<String>>(|lua_ctx| {
            // Add Fennel to Lua's `package.searchers`.
            lua_ctx.mount_fennel()?;
            lua_ctx.compile_fennel_string("(print (+ 1 1))")
        })
        .unwrap();

    // Prints "return print((1 + 1))".
    println!("{}", got);
}

#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