Skip to main content

rsre_lua/
lib.rs

1// SPDX-License-Identifier: MIT
2
3mod re;
4
5#[cfg_attr(feature = "module", mlua::lua_module(name = "rsre"))]
6pub fn rsre_lua(lua: &mlua::Lua) -> mlua::Result<mlua::Table> {
7    let table = lua.create_table()?;
8
9    table.set("Regex", lua.create_proxy::<re::LuaRegex>()?)?;
10    table.set(
11        "escape",
12        lua.create_function(|_, text: mlua::BorrowedStr| {
13            Ok(fancy_regex::escape(&text).to_string())
14        })?,
15    )?;
16
17    Ok(table)
18}