2 releases

Uses old Rust 2015

0.1.1 Feb 3, 2019
0.1.0 Jan 7, 2018

#12 in #calling

MIT license

49KB
961 lines

Luajit RS

Documentation

Crate for interfacing with LuaJIT from Rust, for running high-performance Lua code that can integrate with native-code written in rust.

Getting Started

#[macro_use]
extern crate luajit;

use luajit::{c_int, State};

fn return_42(state: &mut State) -> c_int {
    state.push(42);

    1
}

pub fn main() {
    let mut state = State::new();
    state.open_libs();
    state.do_string(r#"print("Hello world!")"#);

    state.push(lua_fn!(return_42));
    state.set_global("return_42");
    state.do_string(r#"print(return_42())"#);
}

lib.rs:

LuaJIT RS

luajit_rs is a simple wrapper around the LuaJIT project, allowing it to be called from Rust easily and with minimal overhead. Most functions in this crate correspond directly to underlying Lua C API calls

Examples

#[macro_use]
extern crate luajit;

use luajit::{c_int, State};

fn return_42(state: &mut State) -> c_int {
    state.push(42);

    1
}

pub fn main() {
    let mut state = State::new();
    state.open_libs();
    state.do_string(r#"print("Hello world!")"#);

    state.push(lua_fn!(return_42));
    state.set_global("return_42");
    state.do_string(r#"print(return_42())"#);
}

Dependencies

~43KB