[−][src]Struct actix_lua::dev::rlua::prelude::LuaFunction
Handle to an internal Lua function.
Methods
impl<'lua> Function<'lua>[src]
impl<'lua> Function<'lua>pub fn call<A, R>(&self, args: A) -> Result<R, Error> where | [src] |
Calls the function, passing args as function arguments.
The function's return values are converted to the generic type R.
Examples
Call Lua's built-in tostring function:
let lua = Lua::new(); let globals = lua.globals(); let tostring: Function = globals.get("tostring")?; assert_eq!(tostring.call::<_, String>(123)?, "123");
Call a function with multiple arguments:
let lua = Lua::new(); let sum: Function = lua.eval(r#" function(a, b) return a + b end "#, None)?; assert_eq!(sum.call::<_, u32>((3, 4))?, 3 + 4);
pub fn bind<A>(&self, args: A) -> Result<Function<'lua>, Error> where | [src] |
Returns a function that, when called, calls self, passing args as the first set of
arguments.
If any arguments are passed to the returned function, they will be passed after args.
Examples
let lua = Lua::new(); let sum: Function = lua.eval(r#" function(a, b) return a + b end "#, None)?; let bound_a = sum.bind(1)?; assert_eq!(bound_a.call::<_, u32>(2)?, 1 + 2); let bound_a_and_b = sum.bind(13)?.bind(57)?; assert_eq!(bound_a_and_b.call::<_, u32>(())?, 13 + 57);
Trait Implementations
impl<'lua> Debug for Function<'lua>[src]
impl<'lua> Debug for Function<'lua>impl<'lua> Clone for Function<'lua>[src]
impl<'lua> Clone for Function<'lua>fn clone(&self) -> Function<'lua> | [src] |
fn clone_from(&mut self, source: &Self) | 1.0.0 [src] |
Performs copy-assignment from source. Read more
impl<'lua> FromLua<'lua> for Function<'lua>[src]
impl<'lua> FromLua<'lua> for Function<'lua>impl<'lua> ToLua<'lua> for Function<'lua>[src]
impl<'lua> ToLua<'lua> for Function<'lua>Auto Trait Implementations
Blanket Implementations
impl<T> From for T[src]
impl<T> From for Timpl<T, U> Into for T where
U: From<T>, [src]
impl<T, U> Into for T where
U: From<T>, impl<T> ToOwned for T where
T: Clone, [src]
impl<T> ToOwned for T where
T: Clone, impl<T, U> TryFrom for T where
T: From<U>, [src]
impl<T, U> TryFrom for T where
T: From<U>, type Error = !
🔬 This is a nightly-only experimental API. (
try_from)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> | [src] |
impl<T> Borrow for T where
T: ?Sized, [src]
impl<T> Borrow for T where
T: ?Sized, impl<T> BorrowMut for T where
T: ?Sized, [src]
impl<T> BorrowMut for T where
T: ?Sized, fn borrow_mut(&mut self) -> &mut T | [src] |
impl<T, U> TryInto for T where
U: TryFrom<T>, [src]
impl<T, U> TryInto for T where
U: TryFrom<T>, type Error = <U as TryFrom<T>>::Error
🔬 This is a nightly-only experimental API. (
try_from)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error> | [src] |
impl<T> Any for T where
T: 'static + ?Sized, [src]
impl<T> Any for T where
T: 'static + ?Sized, fn get_type_id(&self) -> TypeId | [src] |
impl<T> Erased for T
impl<T> Erased for Timpl<'lua, T> FromLua for T where
T: 'static + UserData + Clone, [src]
impl<'lua, T> FromLua for T where
T: 'static + UserData + Clone, impl<'lua, T> ToLua for T where
T: 'static + UserData + Send, [src]
impl<'lua, T> ToLua for T where
T: 'static + UserData + Send, impl<'lua, T> ToLuaMulti for T where
T: ToLua<'lua>, [src]
impl<'lua, T> ToLuaMulti for T where
T: ToLua<'lua>, fn to_lua_multi(self, lua: &'lua Lua) -> Result<MultiValue<'lua>, Error> | [src] |
impl<'lua, T> FromLuaMulti for T where
T: FromLua<'lua>, [src]
impl<'lua, T> FromLuaMulti for T where
T: FromLua<'lua>, fn from_lua_multi(values: MultiValue<'lua>, lua: &'lua Lua) -> Result<T, Error> | [src] |