[−][src]Struct mlua::Variadic
Wraps a variable number of T
s.
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]
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]
impl<T> DerefMut for Variadic<T>
[src]
impl<T> FromIterator<T> for Variadic<T>
[src]
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
[src]
impl<'lua, T: FromLua<'lua>> FromLuaMulti<'lua> for Variadic<T>
[src]
fn from_lua_multi(values: MultiValue<'lua>, lua: &'lua Lua) -> Result<Self>
[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?
fn into_iter(self) -> Self::IntoIter
[src]
impl<'lua, T: ToLua<'lua>> ToLuaMulti<'lua> for Variadic<T>
[src]
fn to_lua_multi(self, lua: &'lua Lua) -> Result<MultiValue<'lua>>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Variadic<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Variadic<T> where
T: Send,
T: Send,
impl<T> Sync for Variadic<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Variadic<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Variadic<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
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?
fn into_iter(self) -> I
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
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, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,