# Examples
All the examples in this directory can be tried out locally running this command:
```bash
cargo build --example example_name && luajit examples/example_name.lua
```
(Replace `example_name` with the name of the example to try.)
These examples are licensed under the [same license](../LICENSE) as the library itself.
## simple
Simple example of a generic module that returns a table containing three example functions.
Might be a good template to base off most modules.
```bash
cargo build --example simple && luajit examples/simple.lua
```
## num_vector
A more specialized and complex example of a module that introduces a specific userdata to Lua (in this case, Rust's `Vec<f64>`).
Instead of returning a table, the module returns the function that constructs a vector whenever called
(from which the rest of the functions can be accessed).
This example could be a good reference (and showcase) for Lua userdata using Rust.
```bash
cargo build --example num_vector && luajit examples/num_vector.lua
```
## join_varargs
A small but special example of something that, while possible to do in Lua, ends up being far more efficient and simple when done in the C API.
This module returns a a function (`join`) that returns the values returned by a function (its first argument) with all its other arguments,
this can be used to "join" two varargs together.
```bash
cargo build --example join_varargs && luajit examples/join_varargs.lua
```
## test
Used internally (by me) for testing whenever developing new features, not a real example...