Struct rlua::LuaFunction [] [src]

pub struct LuaFunction<'lua>(_);

Handle to an internal Lua function.

Methods

impl<'lua> LuaFunction<'lua>
[src]

Calls the function, passing args as function arguments.

The function's return values are converted to the generic type R.

Returns a function that, when called with no arguments, calls self, passing args as arguments.

This is equivalent to this Lua code:

function bind(f, ...)
    return function() f(...) end
end

Example


let lua = Lua::new();
let globals = lua.globals();

// Bind the argument `123` to Lua's `tostring` function
let tostring: LuaFunction = globals.get("tostring").unwrap();
let tostring_123: LuaFunction = tostring.bind(123i32).unwrap();

// Now we can call `tostring_123` without arguments to get the result of `tostring(123)`
let result: String = tostring_123.call(()).unwrap();
assert_eq!(result, "123");

Trait Implementations

impl<'lua> Clone for LuaFunction<'lua>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<'lua> Debug for LuaFunction<'lua>
[src]

Formats the value using the given formatter.

impl<'lua> ToLua<'lua> for LuaFunction<'lua>
[src]

Performs the conversion.

impl<'lua> FromLua<'lua> for LuaFunction<'lua>
[src]

Performs the conversion.