Crates.io | lua-macros |
lib.rs | lua-macros |
version | 0.1.9 |
source | src |
created_at | 2017-03-03 08:37:24.539818 |
updated_at | 2017-04-12 14:11:36.402902 |
description | Useful macros to join Lua with Rust. |
homepage | |
repository | https://github.com/DenisKolodin/lua-macros |
max_upload_size | |
id | 8783 |
size | 24,680 |
This library provides useful macros to simplify embedding Lua to Rust.
It's based on lua
crate.
Example:
#[macro_use]
extern crate lua_macros;
use lua_macros::lua::{State, Integer};
#[derive(Clone, Debug, PartialEq)]
enum UserEnum {
One,
Two,
Three,
}
lua_userdata!(UserEnum);
fn main() {
let mut state = State::new();
UserEnum::attach(&mut state);
let ud = UserEnum::One;
state.push(ud);
state.push_nil();
let restored = state.to_type::<UserEnum>(-2).unwrap();
let wrong = state.to_type::<UserEnum>(-1);
assert_eq!(restored, UserEnum::One);
assert!(wrong.is_none());
}
Licensed under either of
at your option.
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.