Struct tlua::Function

source ·
pub struct Function<F, P, R> { /* private fields */ }
Expand description

Opaque type containing a Rust function or closure.

In order to build an instance of this struct, you need to use one of the functionN functions. There is one function for each possible number of parameter. For example if you have a function with two parameters, you must use function2. Example:

let f: tlua::Function<_, _, _> = tlua::function2(move |a: i32, b: i32| { });

Note: In practice you will never need to build an object of type Function as an intermediary step. Instead you will most likely always immediately push the function, like in the code below.

You can push a Function object like any other value:

use tlua::Lua;
let lua = Lua::new();

lua.set("foo", tlua::function1(move |a: i32| -> i32 {
    a * 5
}));

The function can then be called from Lua:

lua.exec("a = foo(12)").unwrap();

assert_eq!(lua.get::<i32, _>("a").unwrap(), 60);

Remember that in Lua functions are regular variables, so you can do something like this for example:

lua.exec("bar = foo; a = bar(12)").unwrap();

Multiple return values

The Lua language supports functions that return multiple values at once.

In order to return multiple values from a Rust function, you can return a tuple. The elements of the tuple will be returned in order.

use tlua::Lua;
let lua = Lua::new();

lua.set("values", tlua::function0(move || -> (i32, i32, i32) {
    (12, 24, 48)
}));

lua.exec("a, b, c = values()").unwrap();

assert_eq!(lua.get::<i32, _>("a").unwrap(), 12);
assert_eq!(lua.get::<i32, _>("b").unwrap(), 24);
assert_eq!(lua.get::<i32, _>("c").unwrap(), 48);

Using Result

If you want to return an error to the Lua script, you can use a Result that contains an Err. The error will be returned to Lua as two values: A nil value and the error message.

The error type of the Result must implement the Display trait, and will be turned into a Lua string.

use tlua::Lua;
let lua = Lua::new();
lua.openlibs();

lua.set("err", tlua::function0(move || -> Result<i32, &'static str> {
    Err("something wrong happened")
}));

lua.exec(r#"
    res, err = err();
    assert(res == nil);
    assert(err == "something wrong happened");
"#).unwrap();

This also allows easy use of assert to act like .unwrap() in Rust:

use tlua::Lua;
let lua = Lua::new();
lua.openlibs();

lua.set("err", tlua::function0(move || -> Result<i32, &'static str> {
    Err("something wrong happened")
}));

let ret = lua.exec("res = assert(err())");
assert!(ret.is_err());

Implementations§

source§

impl<F, P, R> Function<F, P, R>

source

pub fn new(function: F) -> Self

Trait Implementations§

source§

impl<F: Clone, P: Clone, R: Clone> Clone for Function<F, P, R>

source§

fn clone(&self) -> Function<F, P, R>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<F, P, R> Debug for Function<F, P, R>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<L, Z, R> Push<L> for Function<Z, (), R>
where L: AsLua, Z: FnMut() -> R, Self: Copy + 'static, (): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

§

type Err = Void

Error that can happen when pushing a value.
source§

fn push_to_lua(&self, lua: L) -> Result<PushGuard<L>, (Void, L)>

Pushes the value on the top of the stack. Read more
source§

fn push_no_err(&self, lua: L) -> PushGuard<L>
where <Self as Push<L>>::Err: Into<Void>,

Same as push_to_lua but can only succeed and is only available if Err implements Into<Void>.
source§

impl<L, Z, R, A: 'static, B: 'static, C: 'static, D: 'static, E: 'static, F: 'static, G: 'static, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> Push<L> for Function<Z, (A, B, C, D, E, F, G, H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(A, B, C, D, E, F, G, H, I, J, K, M, N) -> R, Self: Copy + 'static, (A, B, C, D, E, F, G, H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

§

type Err = Void

Error that can happen when pushing a value.
source§

fn push_to_lua(&self, lua: L) -> Result<PushGuard<L>, (Void, L)>

Pushes the value on the top of the stack. Read more
source§

fn push_no_err(&self, lua: L) -> PushGuard<L>
where <Self as Push<L>>::Err: Into<Void>,

Same as push_to_lua but can only succeed and is only available if Err implements Into<Void>.
source§

impl<L, Z, R, B: 'static, C: 'static, D: 'static, E: 'static, F: 'static, G: 'static, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> Push<L> for Function<Z, (B, C, D, E, F, G, H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(B, C, D, E, F, G, H, I, J, K, M, N) -> R, Self: Copy + 'static, (B, C, D, E, F, G, H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

§

type Err = Void

Error that can happen when pushing a value.
source§

fn push_to_lua(&self, lua: L) -> Result<PushGuard<L>, (Void, L)>

Pushes the value on the top of the stack. Read more
source§

fn push_no_err(&self, lua: L) -> PushGuard<L>
where <Self as Push<L>>::Err: Into<Void>,

Same as push_to_lua but can only succeed and is only available if Err implements Into<Void>.
source§

impl<L, Z, R, C: 'static, D: 'static, E: 'static, F: 'static, G: 'static, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> Push<L> for Function<Z, (C, D, E, F, G, H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(C, D, E, F, G, H, I, J, K, M, N) -> R, Self: Copy + 'static, (C, D, E, F, G, H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

§

type Err = Void

Error that can happen when pushing a value.
source§

fn push_to_lua(&self, lua: L) -> Result<PushGuard<L>, (Void, L)>

Pushes the value on the top of the stack. Read more
source§

fn push_no_err(&self, lua: L) -> PushGuard<L>
where <Self as Push<L>>::Err: Into<Void>,

Same as push_to_lua but can only succeed and is only available if Err implements Into<Void>.
source§

impl<L, Z, R, D: 'static, E: 'static, F: 'static, G: 'static, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> Push<L> for Function<Z, (D, E, F, G, H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(D, E, F, G, H, I, J, K, M, N) -> R, Self: Copy + 'static, (D, E, F, G, H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

§

type Err = Void

Error that can happen when pushing a value.
source§

fn push_to_lua(&self, lua: L) -> Result<PushGuard<L>, (Void, L)>

Pushes the value on the top of the stack. Read more
source§

fn push_no_err(&self, lua: L) -> PushGuard<L>
where <Self as Push<L>>::Err: Into<Void>,

Same as push_to_lua but can only succeed and is only available if Err implements Into<Void>.
source§

impl<L, Z, R, E: 'static, F: 'static, G: 'static, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> Push<L> for Function<Z, (E, F, G, H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(E, F, G, H, I, J, K, M, N) -> R, Self: Copy + 'static, (E, F, G, H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

§

type Err = Void

Error that can happen when pushing a value.
source§

fn push_to_lua(&self, lua: L) -> Result<PushGuard<L>, (Void, L)>

Pushes the value on the top of the stack. Read more
source§

fn push_no_err(&self, lua: L) -> PushGuard<L>
where <Self as Push<L>>::Err: Into<Void>,

Same as push_to_lua but can only succeed and is only available if Err implements Into<Void>.
source§

impl<L, Z, R, F: 'static, G: 'static, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> Push<L> for Function<Z, (F, G, H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(F, G, H, I, J, K, M, N) -> R, Self: Copy + 'static, (F, G, H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

§

type Err = Void

Error that can happen when pushing a value.
source§

fn push_to_lua(&self, lua: L) -> Result<PushGuard<L>, (Void, L)>

Pushes the value on the top of the stack. Read more
source§

fn push_no_err(&self, lua: L) -> PushGuard<L>
where <Self as Push<L>>::Err: Into<Void>,

Same as push_to_lua but can only succeed and is only available if Err implements Into<Void>.
source§

impl<L, Z, R, G: 'static, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> Push<L> for Function<Z, (G, H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(G, H, I, J, K, M, N) -> R, Self: Copy + 'static, (G, H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

§

type Err = Void

Error that can happen when pushing a value.
source§

fn push_to_lua(&self, lua: L) -> Result<PushGuard<L>, (Void, L)>

Pushes the value on the top of the stack. Read more
source§

fn push_no_err(&self, lua: L) -> PushGuard<L>
where <Self as Push<L>>::Err: Into<Void>,

Same as push_to_lua but can only succeed and is only available if Err implements Into<Void>.
source§

impl<L, Z, R, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> Push<L> for Function<Z, (H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(H, I, J, K, M, N) -> R, Self: Copy + 'static, (H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

§

type Err = Void

Error that can happen when pushing a value.
source§

fn push_to_lua(&self, lua: L) -> Result<PushGuard<L>, (Void, L)>

Pushes the value on the top of the stack. Read more
source§

fn push_no_err(&self, lua: L) -> PushGuard<L>
where <Self as Push<L>>::Err: Into<Void>,

Same as push_to_lua but can only succeed and is only available if Err implements Into<Void>.
source§

impl<L, Z, R, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> Push<L> for Function<Z, (I, J, K, M, N), R>
where L: AsLua, Z: FnMut(I, J, K, M, N) -> R, Self: Copy + 'static, (I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

§

type Err = Void

Error that can happen when pushing a value.
source§

fn push_to_lua(&self, lua: L) -> Result<PushGuard<L>, (Void, L)>

Pushes the value on the top of the stack. Read more
source§

fn push_no_err(&self, lua: L) -> PushGuard<L>
where <Self as Push<L>>::Err: Into<Void>,

Same as push_to_lua but can only succeed and is only available if Err implements Into<Void>.
source§

impl<L, Z, R, J: 'static, K: 'static, M: 'static, N: 'static> Push<L> for Function<Z, (J, K, M, N), R>
where L: AsLua, Z: FnMut(J, K, M, N) -> R, Self: Copy + 'static, (J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

§

type Err = Void

Error that can happen when pushing a value.
source§

fn push_to_lua(&self, lua: L) -> Result<PushGuard<L>, (Void, L)>

Pushes the value on the top of the stack. Read more
source§

fn push_no_err(&self, lua: L) -> PushGuard<L>
where <Self as Push<L>>::Err: Into<Void>,

Same as push_to_lua but can only succeed and is only available if Err implements Into<Void>.
source§

impl<L, Z, R, K: 'static, M: 'static, N: 'static> Push<L> for Function<Z, (K, M, N), R>
where L: AsLua, Z: FnMut(K, M, N) -> R, Self: Copy + 'static, (K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

§

type Err = Void

Error that can happen when pushing a value.
source§

fn push_to_lua(&self, lua: L) -> Result<PushGuard<L>, (Void, L)>

Pushes the value on the top of the stack. Read more
source§

fn push_no_err(&self, lua: L) -> PushGuard<L>
where <Self as Push<L>>::Err: Into<Void>,

Same as push_to_lua but can only succeed and is only available if Err implements Into<Void>.
source§

impl<L, Z, R, M: 'static, N: 'static> Push<L> for Function<Z, (M, N), R>
where L: AsLua, Z: FnMut(M, N) -> R, Self: Copy + 'static, (M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

§

type Err = Void

Error that can happen when pushing a value.
source§

fn push_to_lua(&self, lua: L) -> Result<PushGuard<L>, (Void, L)>

Pushes the value on the top of the stack. Read more
source§

fn push_no_err(&self, lua: L) -> PushGuard<L>
where <Self as Push<L>>::Err: Into<Void>,

Same as push_to_lua but can only succeed and is only available if Err implements Into<Void>.
source§

impl<L, Z, R, N: 'static> Push<L> for Function<Z, (N,), R>
where L: AsLua, Z: FnMut(N) -> R, Self: Copy + 'static, (N,): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

§

type Err = Void

Error that can happen when pushing a value.
source§

fn push_to_lua(&self, lua: L) -> Result<PushGuard<L>, (Void, L)>

Pushes the value on the top of the stack. Read more
source§

fn push_no_err(&self, lua: L) -> PushGuard<L>
where <Self as Push<L>>::Err: Into<Void>,

Same as push_to_lua but can only succeed and is only available if Err implements Into<Void>.
source§

impl<L, Z, R> PushInto<L> for Function<Z, (), R>
where L: AsLua, Z: FnMut() -> R + 'static, (): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

§

type Err = Void

source§

fn push_into_lua(self, lua: L) -> Result<PushGuard<L>, (Void, L)>

Push the value into lua by value
source§

fn push_into_no_err(self, lua: L) -> PushGuard<L>
where Self: Sized, <Self as PushInto<L>>::Err: Into<Void>,

Same as push_into_lua but can only succeed and is only available if Err implements Into<Void>.
source§

impl<L, Z, R, A: 'static, B: 'static, C: 'static, D: 'static, E: 'static, F: 'static, G: 'static, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> PushInto<L> for Function<Z, (A, B, C, D, E, F, G, H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(A, B, C, D, E, F, G, H, I, J, K, M, N) -> R + 'static, (A, B, C, D, E, F, G, H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

§

type Err = Void

source§

fn push_into_lua(self, lua: L) -> Result<PushGuard<L>, (Void, L)>

Push the value into lua by value
source§

fn push_into_no_err(self, lua: L) -> PushGuard<L>
where Self: Sized, <Self as PushInto<L>>::Err: Into<Void>,

Same as push_into_lua but can only succeed and is only available if Err implements Into<Void>.
source§

impl<L, Z, R, B: 'static, C: 'static, D: 'static, E: 'static, F: 'static, G: 'static, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> PushInto<L> for Function<Z, (B, C, D, E, F, G, H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(B, C, D, E, F, G, H, I, J, K, M, N) -> R + 'static, (B, C, D, E, F, G, H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

§

type Err = Void

source§

fn push_into_lua(self, lua: L) -> Result<PushGuard<L>, (Void, L)>

Push the value into lua by value
source§

fn push_into_no_err(self, lua: L) -> PushGuard<L>
where Self: Sized, <Self as PushInto<L>>::Err: Into<Void>,

Same as push_into_lua but can only succeed and is only available if Err implements Into<Void>.
source§

impl<L, Z, R, C: 'static, D: 'static, E: 'static, F: 'static, G: 'static, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> PushInto<L> for Function<Z, (C, D, E, F, G, H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(C, D, E, F, G, H, I, J, K, M, N) -> R + 'static, (C, D, E, F, G, H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

§

type Err = Void

source§

fn push_into_lua(self, lua: L) -> Result<PushGuard<L>, (Void, L)>

Push the value into lua by value
source§

fn push_into_no_err(self, lua: L) -> PushGuard<L>
where Self: Sized, <Self as PushInto<L>>::Err: Into<Void>,

Same as push_into_lua but can only succeed and is only available if Err implements Into<Void>.
source§

impl<L, Z, R, D: 'static, E: 'static, F: 'static, G: 'static, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> PushInto<L> for Function<Z, (D, E, F, G, H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(D, E, F, G, H, I, J, K, M, N) -> R + 'static, (D, E, F, G, H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

§

type Err = Void

source§

fn push_into_lua(self, lua: L) -> Result<PushGuard<L>, (Void, L)>

Push the value into lua by value
source§

fn push_into_no_err(self, lua: L) -> PushGuard<L>
where Self: Sized, <Self as PushInto<L>>::Err: Into<Void>,

Same as push_into_lua but can only succeed and is only available if Err implements Into<Void>.
source§

impl<L, Z, R, E: 'static, F: 'static, G: 'static, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> PushInto<L> for Function<Z, (E, F, G, H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(E, F, G, H, I, J, K, M, N) -> R + 'static, (E, F, G, H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

§

type Err = Void

source§

fn push_into_lua(self, lua: L) -> Result<PushGuard<L>, (Void, L)>

Push the value into lua by value
source§

fn push_into_no_err(self, lua: L) -> PushGuard<L>
where Self: Sized, <Self as PushInto<L>>::Err: Into<Void>,

Same as push_into_lua but can only succeed and is only available if Err implements Into<Void>.
source§

impl<L, Z, R, F: 'static, G: 'static, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> PushInto<L> for Function<Z, (F, G, H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(F, G, H, I, J, K, M, N) -> R + 'static, (F, G, H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

§

type Err = Void

source§

fn push_into_lua(self, lua: L) -> Result<PushGuard<L>, (Void, L)>

Push the value into lua by value
source§

fn push_into_no_err(self, lua: L) -> PushGuard<L>
where Self: Sized, <Self as PushInto<L>>::Err: Into<Void>,

Same as push_into_lua but can only succeed and is only available if Err implements Into<Void>.
source§

impl<L, Z, R, G: 'static, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> PushInto<L> for Function<Z, (G, H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(G, H, I, J, K, M, N) -> R + 'static, (G, H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

§

type Err = Void

source§

fn push_into_lua(self, lua: L) -> Result<PushGuard<L>, (Void, L)>

Push the value into lua by value
source§

fn push_into_no_err(self, lua: L) -> PushGuard<L>
where Self: Sized, <Self as PushInto<L>>::Err: Into<Void>,

Same as push_into_lua but can only succeed and is only available if Err implements Into<Void>.
source§

impl<L, Z, R, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> PushInto<L> for Function<Z, (H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(H, I, J, K, M, N) -> R + 'static, (H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

§

type Err = Void

source§

fn push_into_lua(self, lua: L) -> Result<PushGuard<L>, (Void, L)>

Push the value into lua by value
source§

fn push_into_no_err(self, lua: L) -> PushGuard<L>
where Self: Sized, <Self as PushInto<L>>::Err: Into<Void>,

Same as push_into_lua but can only succeed and is only available if Err implements Into<Void>.
source§

impl<L, Z, R, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> PushInto<L> for Function<Z, (I, J, K, M, N), R>
where L: AsLua, Z: FnMut(I, J, K, M, N) -> R + 'static, (I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

§

type Err = Void

source§

fn push_into_lua(self, lua: L) -> Result<PushGuard<L>, (Void, L)>

Push the value into lua by value
source§

fn push_into_no_err(self, lua: L) -> PushGuard<L>
where Self: Sized, <Self as PushInto<L>>::Err: Into<Void>,

Same as push_into_lua but can only succeed and is only available if Err implements Into<Void>.
source§

impl<L, Z, R, J: 'static, K: 'static, M: 'static, N: 'static> PushInto<L> for Function<Z, (J, K, M, N), R>
where L: AsLua, Z: FnMut(J, K, M, N) -> R + 'static, (J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

§

type Err = Void

source§

fn push_into_lua(self, lua: L) -> Result<PushGuard<L>, (Void, L)>

Push the value into lua by value
source§

fn push_into_no_err(self, lua: L) -> PushGuard<L>
where Self: Sized, <Self as PushInto<L>>::Err: Into<Void>,

Same as push_into_lua but can only succeed and is only available if Err implements Into<Void>.
source§

impl<L, Z, R, K: 'static, M: 'static, N: 'static> PushInto<L> for Function<Z, (K, M, N), R>
where L: AsLua, Z: FnMut(K, M, N) -> R + 'static, (K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

§

type Err = Void

source§

fn push_into_lua(self, lua: L) -> Result<PushGuard<L>, (Void, L)>

Push the value into lua by value
source§

fn push_into_no_err(self, lua: L) -> PushGuard<L>
where Self: Sized, <Self as PushInto<L>>::Err: Into<Void>,

Same as push_into_lua but can only succeed and is only available if Err implements Into<Void>.
source§

impl<L, Z, R, M: 'static, N: 'static> PushInto<L> for Function<Z, (M, N), R>
where L: AsLua, Z: FnMut(M, N) -> R + 'static, (M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

§

type Err = Void

source§

fn push_into_lua(self, lua: L) -> Result<PushGuard<L>, (Void, L)>

Push the value into lua by value
source§

fn push_into_no_err(self, lua: L) -> PushGuard<L>
where Self: Sized, <Self as PushInto<L>>::Err: Into<Void>,

Same as push_into_lua but can only succeed and is only available if Err implements Into<Void>.
source§

impl<L, Z, R, N: 'static> PushInto<L> for Function<Z, (N,), R>
where L: AsLua, Z: FnMut(N) -> R + 'static, (N,): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

§

type Err = Void

source§

fn push_into_lua(self, lua: L) -> Result<PushGuard<L>, (Void, L)>

Push the value into lua by value
source§

fn push_into_no_err(self, lua: L) -> PushGuard<L>
where Self: Sized, <Self as PushInto<L>>::Err: Into<Void>,

Same as push_into_lua but can only succeed and is only available if Err implements Into<Void>.
source§

impl<F: Copy, P: Copy, R: Copy> Copy for Function<F, P, R>

source§

impl<L, Z, R> PushOne<L> for Function<Z, (), R>
where L: AsLua, Z: FnMut() -> R, Self: Copy + 'static, (): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

source§

impl<L, Z, R, A: 'static, B: 'static, C: 'static, D: 'static, E: 'static, F: 'static, G: 'static, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> PushOne<L> for Function<Z, (A, B, C, D, E, F, G, H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(A, B, C, D, E, F, G, H, I, J, K, M, N) -> R, Self: Copy + 'static, (A, B, C, D, E, F, G, H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

source§

impl<L, Z, R, B: 'static, C: 'static, D: 'static, E: 'static, F: 'static, G: 'static, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> PushOne<L> for Function<Z, (B, C, D, E, F, G, H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(B, C, D, E, F, G, H, I, J, K, M, N) -> R, Self: Copy + 'static, (B, C, D, E, F, G, H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

source§

impl<L, Z, R, C: 'static, D: 'static, E: 'static, F: 'static, G: 'static, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> PushOne<L> for Function<Z, (C, D, E, F, G, H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(C, D, E, F, G, H, I, J, K, M, N) -> R, Self: Copy + 'static, (C, D, E, F, G, H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

source§

impl<L, Z, R, D: 'static, E: 'static, F: 'static, G: 'static, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> PushOne<L> for Function<Z, (D, E, F, G, H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(D, E, F, G, H, I, J, K, M, N) -> R, Self: Copy + 'static, (D, E, F, G, H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

source§

impl<L, Z, R, E: 'static, F: 'static, G: 'static, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> PushOne<L> for Function<Z, (E, F, G, H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(E, F, G, H, I, J, K, M, N) -> R, Self: Copy + 'static, (E, F, G, H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

source§

impl<L, Z, R, F: 'static, G: 'static, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> PushOne<L> for Function<Z, (F, G, H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(F, G, H, I, J, K, M, N) -> R, Self: Copy + 'static, (F, G, H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

source§

impl<L, Z, R, G: 'static, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> PushOne<L> for Function<Z, (G, H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(G, H, I, J, K, M, N) -> R, Self: Copy + 'static, (G, H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

source§

impl<L, Z, R, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> PushOne<L> for Function<Z, (H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(H, I, J, K, M, N) -> R, Self: Copy + 'static, (H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

source§

impl<L, Z, R, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> PushOne<L> for Function<Z, (I, J, K, M, N), R>
where L: AsLua, Z: FnMut(I, J, K, M, N) -> R, Self: Copy + 'static, (I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

source§

impl<L, Z, R, J: 'static, K: 'static, M: 'static, N: 'static> PushOne<L> for Function<Z, (J, K, M, N), R>
where L: AsLua, Z: FnMut(J, K, M, N) -> R, Self: Copy + 'static, (J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

source§

impl<L, Z, R, K: 'static, M: 'static, N: 'static> PushOne<L> for Function<Z, (K, M, N), R>
where L: AsLua, Z: FnMut(K, M, N) -> R, Self: Copy + 'static, (K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

source§

impl<L, Z, R, M: 'static, N: 'static> PushOne<L> for Function<Z, (M, N), R>
where L: AsLua, Z: FnMut(M, N) -> R, Self: Copy + 'static, (M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

source§

impl<L, Z, R, N: 'static> PushOne<L> for Function<Z, (N,), R>
where L: AsLua, Z: FnMut(N) -> R, Self: Copy + 'static, (N,): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

source§

impl<L, Z, R> PushOneInto<L> for Function<Z, (), R>
where L: AsLua, Z: FnMut() -> R + 'static, (): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

source§

impl<L, Z, R, A: 'static, B: 'static, C: 'static, D: 'static, E: 'static, F: 'static, G: 'static, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> PushOneInto<L> for Function<Z, (A, B, C, D, E, F, G, H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(A, B, C, D, E, F, G, H, I, J, K, M, N) -> R + 'static, (A, B, C, D, E, F, G, H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

source§

impl<L, Z, R, B: 'static, C: 'static, D: 'static, E: 'static, F: 'static, G: 'static, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> PushOneInto<L> for Function<Z, (B, C, D, E, F, G, H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(B, C, D, E, F, G, H, I, J, K, M, N) -> R + 'static, (B, C, D, E, F, G, H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

source§

impl<L, Z, R, C: 'static, D: 'static, E: 'static, F: 'static, G: 'static, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> PushOneInto<L> for Function<Z, (C, D, E, F, G, H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(C, D, E, F, G, H, I, J, K, M, N) -> R + 'static, (C, D, E, F, G, H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

source§

impl<L, Z, R, D: 'static, E: 'static, F: 'static, G: 'static, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> PushOneInto<L> for Function<Z, (D, E, F, G, H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(D, E, F, G, H, I, J, K, M, N) -> R + 'static, (D, E, F, G, H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

source§

impl<L, Z, R, E: 'static, F: 'static, G: 'static, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> PushOneInto<L> for Function<Z, (E, F, G, H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(E, F, G, H, I, J, K, M, N) -> R + 'static, (E, F, G, H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

source§

impl<L, Z, R, F: 'static, G: 'static, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> PushOneInto<L> for Function<Z, (F, G, H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(F, G, H, I, J, K, M, N) -> R + 'static, (F, G, H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

source§

impl<L, Z, R, G: 'static, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> PushOneInto<L> for Function<Z, (G, H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(G, H, I, J, K, M, N) -> R + 'static, (G, H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

source§

impl<L, Z, R, H: 'static, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> PushOneInto<L> for Function<Z, (H, I, J, K, M, N), R>
where L: AsLua, Z: FnMut(H, I, J, K, M, N) -> R + 'static, (H, I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

source§

impl<L, Z, R, I: 'static, J: 'static, K: 'static, M: 'static, N: 'static> PushOneInto<L> for Function<Z, (I, J, K, M, N), R>
where L: AsLua, Z: FnMut(I, J, K, M, N) -> R + 'static, (I, J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

source§

impl<L, Z, R, J: 'static, K: 'static, M: 'static, N: 'static> PushOneInto<L> for Function<Z, (J, K, M, N), R>
where L: AsLua, Z: FnMut(J, K, M, N) -> R + 'static, (J, K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

source§

impl<L, Z, R, K: 'static, M: 'static, N: 'static> PushOneInto<L> for Function<Z, (K, M, N), R>
where L: AsLua, Z: FnMut(K, M, N) -> R + 'static, (K, M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

source§

impl<L, Z, R, M: 'static, N: 'static> PushOneInto<L> for Function<Z, (M, N), R>
where L: AsLua, Z: FnMut(M, N) -> R + 'static, (M, N): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

source§

impl<L, Z, R, N: 'static> PushOneInto<L> for Function<Z, (N,), R>
where L: AsLua, Z: FnMut(N) -> R + 'static, (N,): for<'p> LuaRead<&'p InsideCallback>, R: PushInto<InsideCallback> + 'static,

Auto Trait Implementations§

§

impl<F, P, R> RefUnwindSafe for Function<F, P, R>

§

impl<F, P, R> Send for Function<F, P, R>
where F: Send, P: Send, R: Send,

§

impl<F, P, R> Sync for Function<F, P, R>
where F: Sync, P: Sync, R: Sync,

§

impl<F, P, R> Unpin for Function<F, P, R>
where F: Unpin, P: Unpin, R: Unpin,

§

impl<F, P, R> UnwindSafe for Function<F, P, R>
where F: UnwindSafe, P: UnwindSafe, R: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.