diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/conversion.rs | 4 | ||||
-rw-r--r-- | src/lua.rs | 5 | ||||
-rw-r--r-- | src/value.rs | 2 |
3 files changed, 7 insertions, 4 deletions
diff --git a/src/conversion.rs b/src/conversion.rs index d4c589f..67726db 100644 --- a/src/conversion.rs +++ b/src/conversion.rs @@ -364,7 +364,9 @@ macro_rules! lua_convert_int { impl<'lua> FromLua<'lua> for $x { fn from_lua(value: Value<'lua>, lua: &'lua Lua) -> Result<Self> { let ty = value.type_name(); - (if let Some(i) = lua.coerce_integer(value.clone())? { + (if let Value::Integer(i) = value { + cast(i) + } else if let Some(i) = lua.coerce_integer(value.clone())? { cast(i) } else { cast(lua.coerce_number(value)?.ok_or_else(|| { @@ -2230,13 +2230,14 @@ impl Lua { args.push_front(lua.pop_value()); } - let results = ((*upvalue).func)(&lua, args)?; + let mut results = ((*upvalue).func)(&lua, args)?; let nresults = results.len() as c_int; check_stack(state, nresults)?; - for r in results { + for r in results.drain_all() { lua.push_value(r)?; } + lua.cache_multivalue(results); Ok(nresults) }) diff --git a/src/value.rs b/src/value.rs index 06e88dc..eefbf8a 100644 --- a/src/value.rs +++ b/src/value.rs @@ -53,7 +53,7 @@ pub enum Value<'lua> { pub use self::Value::Nil; impl<'lua> Value<'lua> { - pub fn type_name(&self) -> &'static str { + pub const fn type_name(&self) -> &'static str { match *self { Value::Nil => "nil", Value::Boolean(_) => "boolean", |