summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/conversion.rs4
-rw-r--r--src/lua.rs5
-rw-r--r--src/value.rs2
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(|| {
diff --git a/src/lua.rs b/src/lua.rs
index 1582b2a..5ba90e2 100644
--- a/src/lua.rs
+++ b/src/lua.rs
@@ -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",