rsre-lua 0.3.1

a regex lua module using the fancy-regex rust crate
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// SPDX-License-Identifier: MIT

mod re;

#[cfg_attr(feature = "module", mlua::lua_module(name = "rsre"))]
pub fn rsre_lua(lua: &mlua::Lua) -> mlua::Result<mlua::Table> {
    let table = lua.create_table()?;

    table.set("Regex", lua.create_proxy::<re::LuaRegex>()?)?;
    table.set(
        "escape",
        lua.create_function(|_, text: mlua::BorrowedStr| {
            Ok(fancy_regex::escape(&text).to_string())
        })?,
    )?;

    Ok(table)
}