diff options
Diffstat (limited to 'src/multi.rs')
-rw-r--r-- | src/multi.rs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/multi.rs b/src/multi.rs index 83d3052..56c8a4c 100644 --- a/src/multi.rs +++ b/src/multi.rs @@ -2,9 +2,9 @@ use std::iter::FromIterator; use std::ops::{Deref, DerefMut}; use std::result::Result as StdResult; -use error::Result; -use lua::Lua; -use value::{FromLua, FromLuaMulti, MultiValue, Nil, ToLua, ToLuaMulti}; +use crate::error::Result; +use crate::lua::Lua; +use crate::value::{FromLua, FromLuaMulti, MultiValue, Nil, ToLua, ToLuaMulti}; /// Result is convertible to `MultiValue` following the common Lua idiom of returning the result /// on success, or in the case of an error, returning `nil` and an error message. @@ -62,21 +62,16 @@ impl<'lua> FromLuaMulti<'lua> for MultiValue<'lua> { /// # Examples /// /// ``` -/// # extern crate rlua; /// # use rlua::{Lua, Variadic, Result}; -/// # fn try_main() -> Result<()> { +/// # fn main() -> Result<()> { /// let lua = Lua::new(); -/// /// let add = lua.create_function(|_, vals: Variadic<f64>| -> Result<f64> { /// Ok(vals.iter().sum()) /// }).unwrap(); /// lua.globals().set("add", add)?; -/// assert_eq!(lua.eval::<_, f64>("add(3, 2, 5)", None)?, 10.0); +/// assert_eq!(lua.load("add(3, 2, 5)").eval::<f32>()?, 10.0); /// # Ok(()) /// # } -/// # fn main() { -/// # try_main().unwrap(); -/// # } /// ``` /// /// [`FromLua`]: trait.FromLua.html @@ -91,6 +86,12 @@ impl<T> Variadic<T> { } } +impl<T> Default for Variadic<T> { + fn default() -> Variadic<T> { + Variadic::new() + } +} + impl<T> FromIterator<T> for Variadic<T> { fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self { Variadic(Vec::from_iter(iter)) |