Skip to content

Commit 2557a7a

Browse files
committed
Add basic functions to test module build
1 parent 85d1b6b commit 2557a7a

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ version = "0.0.0"
44
authors = ["Caleb Maclennan <[email protected]>"]
55
edition = "2018"
66

7+
[lib]
8+
crate-type = ["cdylib"]
9+
710
[dependencies]
811
pulldown-cmark = "0.7.1"
912
mlua = "0.3.2"

src/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
#[macro_use]
2+
extern crate mlua_derive;
3+
4+
use mlua::prelude::*;
5+
use pulldown_cmark::{Options, Parser};
6+
7+
fn hello(_: &Lua, name: String) -> LuaResult<()> {
8+
println!("hello, {}!", name);
9+
Ok(())
10+
}
11+
12+
#[lua_module]
13+
fn my_module(lua: &Lua) -> LuaResult<LuaTable> {
14+
let exports = lua.create_table()?;
15+
exports.set("hello", lua.create_function(hello)?)?;
16+
Ok(exports)
17+
}
18+
119
#[cfg(test)]
220
mod tests {
321
#[test]

0 commit comments

Comments
 (0)