[][src]Struct mlua::Variadic

pub struct Variadic<T>(_);

Wraps a variable number of Ts.

Can be used to work with variadic functions more easily. Using this type as the last argument of a Rust callback will accept any number of arguments from Lua and convert them to the type T using FromLua. Variadic<T> can also be returned from a callback, returning a variable number of values to Lua.

The MultiValue type is equivalent to Variadic<Value>.

Examples

let add = lua.create_function(|_, vals: Variadic<f64>| -> Result<f64> {
    Ok(vals.iter().sum())
})?;
lua.globals().set("add", add)?;
assert_eq!(lua.load("add(3, 2, 5)").eval::<f32>()?, 10.0);

Implementations

impl<T> Variadic<T>[src]

pub fn new() -> Variadic<T>[src]

Creates an empty Variadic wrapper containing no values.

Trait Implementations

impl<T: Clone> Clone for Variadic<T>[src]

impl<T: Debug> Debug for Variadic<T>[src]

impl<T> Default for Variadic<T>[src]

impl<T> Deref for Variadic<T>[src]

type Target = Vec<T>

The resulting type after dereferencing.

impl<T> DerefMut for Variadic<T>[src]

impl<T> FromIterator<T> for Variadic<T>[src]

impl<'lua, T: FromLua<'lua>> FromLuaMulti<'lua> for Variadic<T>[src]

impl<T> IntoIterator for Variadic<T>[src]

type Item = T

The type of the elements being iterated over.

type IntoIter = <Vec<T> as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?

impl<'lua, T: ToLua<'lua>> ToLuaMulti<'lua> for Variadic<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Variadic<T> where
    T: RefUnwindSafe

impl<T> Send for Variadic<T> where
    T: Send

impl<T> Sync for Variadic<T> where
    T: Sync

impl<T> Unpin for Variadic<T> where
    T: Unpin

impl<T> UnwindSafe for Variadic<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.