format with up-to-date rustfmt
This commit is contained in:
parent
e6688e1db2
commit
2e1bdb64c0
|
@ -58,14 +58,15 @@ fn call_add_function(c: &mut Criterion) {
|
||||||
|| {
|
|| {
|
||||||
let lua = Lua::new();
|
let lua = Lua::new();
|
||||||
let f = {
|
let f = {
|
||||||
let f: LuaFunction = lua.eval(
|
let f: LuaFunction =
|
||||||
r#"
|
lua.eval(
|
||||||
|
r#"
|
||||||
function(a, b, c)
|
function(a, b, c)
|
||||||
return a + b + c
|
return a + b + c
|
||||||
end
|
end
|
||||||
"#,
|
"#,
|
||||||
None,
|
None,
|
||||||
).unwrap();
|
).unwrap();
|
||||||
lua.create_registry_value(f).unwrap()
|
lua.create_registry_value(f).unwrap()
|
||||||
};
|
};
|
||||||
(lua, f)
|
(lua, f)
|
||||||
|
@ -89,20 +90,21 @@ fn call_add_callback(c: &mut Criterion) {
|
||||||
|| {
|
|| {
|
||||||
let lua = Lua::new();
|
let lua = Lua::new();
|
||||||
let f = {
|
let f = {
|
||||||
let c: LuaFunction = lua.create_function(|_, (a, b, c): (i64, i64, i64)| {
|
let c: LuaFunction = lua
|
||||||
Ok(a + b + c)
|
.create_function(|_, (a, b, c): (i64, i64, i64)| Ok(a + b + c))
|
||||||
}).unwrap();
|
.unwrap();
|
||||||
lua.globals().set("callback", c).unwrap();
|
lua.globals().set("callback", c).unwrap();
|
||||||
let f: LuaFunction = lua.eval(
|
let f: LuaFunction =
|
||||||
r#"
|
lua.eval(
|
||||||
|
r#"
|
||||||
function()
|
function()
|
||||||
for i = 1,10 do
|
for i = 1,10 do
|
||||||
callback(i, i, i)
|
callback(i, i, i)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
"#,
|
"#,
|
||||||
None,
|
None,
|
||||||
).unwrap();
|
).unwrap();
|
||||||
lua.create_registry_value(f).unwrap()
|
lua.create_registry_value(f).unwrap()
|
||||||
};
|
};
|
||||||
(lua, f)
|
(lua, f)
|
||||||
|
@ -129,16 +131,17 @@ fn call_append_callback(c: &mut Criterion) {
|
||||||
Ok(format!("{}{}", a.to_str()?, b.to_str()?))
|
Ok(format!("{}{}", a.to_str()?, b.to_str()?))
|
||||||
}).unwrap();
|
}).unwrap();
|
||||||
lua.globals().set("callback", c).unwrap();
|
lua.globals().set("callback", c).unwrap();
|
||||||
let f: LuaFunction = lua.eval(
|
let f: LuaFunction =
|
||||||
r#"
|
lua.eval(
|
||||||
|
r#"
|
||||||
function()
|
function()
|
||||||
for _ = 1,10 do
|
for _ = 1,10 do
|
||||||
callback("a", "b")
|
callback("a", "b")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
"#,
|
"#,
|
||||||
None,
|
None,
|
||||||
).unwrap();
|
).unwrap();
|
||||||
lua.create_registry_value(f).unwrap()
|
lua.create_registry_value(f).unwrap()
|
||||||
};
|
};
|
||||||
(lua, f)
|
(lua, f)
|
||||||
|
|
|
@ -3,14 +3,14 @@ use std::hash::{BuildHasher, Hash};
|
||||||
use std::string::String as StdString;
|
use std::string::String as StdString;
|
||||||
|
|
||||||
use error::{Error, Result};
|
use error::{Error, Result};
|
||||||
use types::{Integer, LightUserData, Number};
|
use function::Function;
|
||||||
|
use lua::Lua;
|
||||||
use string::String;
|
use string::String;
|
||||||
use table::Table;
|
use table::Table;
|
||||||
use userdata::{AnyUserData, UserData};
|
|
||||||
use function::Function;
|
|
||||||
use thread::Thread;
|
use thread::Thread;
|
||||||
|
use types::{Integer, LightUserData, Number};
|
||||||
|
use userdata::{AnyUserData, UserData};
|
||||||
use value::{FromLua, Nil, ToLua, Value};
|
use value::{FromLua, Nil, ToLua, Value};
|
||||||
use lua::Lua;
|
|
||||||
|
|
||||||
impl<'lua> ToLua<'lua> for Value<'lua> {
|
impl<'lua> ToLua<'lua> for Value<'lua> {
|
||||||
fn to_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
|
fn to_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
|
||||||
|
@ -204,7 +204,7 @@ impl<'lua, 'a> ToLua<'lua> for &'a str {
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! lua_convert_int {
|
macro_rules! lua_convert_int {
|
||||||
($x: ty) => {
|
($x:ty) => {
|
||||||
impl<'lua> ToLua<'lua> for $x {
|
impl<'lua> ToLua<'lua> for $x {
|
||||||
fn to_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
|
fn to_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
|
||||||
Ok(Value::Integer(self as Integer))
|
Ok(Value::Integer(self as Integer))
|
||||||
|
@ -216,7 +216,7 @@ macro_rules! lua_convert_int {
|
||||||
Ok(lua.coerce_integer(value)? as $x)
|
Ok(lua.coerce_integer(value)? as $x)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_convert_int!(i8);
|
lua_convert_int!(i8);
|
||||||
|
@ -231,7 +231,7 @@ lua_convert_int!(isize);
|
||||||
lua_convert_int!(usize);
|
lua_convert_int!(usize);
|
||||||
|
|
||||||
macro_rules! lua_convert_float {
|
macro_rules! lua_convert_float {
|
||||||
($x: ty) => {
|
($x:ty) => {
|
||||||
impl<'lua> ToLua<'lua> for $x {
|
impl<'lua> ToLua<'lua> for $x {
|
||||||
fn to_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
|
fn to_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
|
||||||
Ok(Value::Number(self as Number))
|
Ok(Value::Number(self as Number))
|
||||||
|
@ -243,7 +243,7 @@ macro_rules! lua_convert_float {
|
||||||
Ok(lua.coerce_number(value)? as $x)
|
Ok(lua.coerce_number(value)? as $x)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_convert_float!(f32);
|
lua_convert_float!(f32);
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
#![allow(unused)]
|
#![allow(unused)]
|
||||||
|
|
||||||
use std::ptr;
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::os::raw::{c_char, c_double, c_int, c_longlong, c_uchar, c_void};
|
use std::os::raw::{c_char, c_double, c_int, c_longlong, c_uchar, c_void};
|
||||||
|
use std::ptr;
|
||||||
|
|
||||||
pub type lua_Integer = c_longlong;
|
pub type lua_Integer = c_longlong;
|
||||||
pub type lua_Number = c_double;
|
pub type lua_Number = c_double;
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
use std::ptr;
|
|
||||||
use std::os::raw::c_int;
|
use std::os::raw::c_int;
|
||||||
|
use std::ptr;
|
||||||
|
|
||||||
use ffi;
|
|
||||||
use error::{Error, Result};
|
use error::{Error, Result};
|
||||||
use util::{assert_stack, check_stack, error_traceback, pop_error, protect_lua_closure, StackGuard};
|
use ffi;
|
||||||
use types::LuaRef;
|
use types::LuaRef;
|
||||||
|
use util::{
|
||||||
|
assert_stack, check_stack, error_traceback, pop_error, protect_lua_closure, StackGuard,
|
||||||
|
};
|
||||||
use value::{FromLuaMulti, MultiValue, ToLuaMulti};
|
use value::{FromLuaMulti, MultiValue, ToLuaMulti};
|
||||||
|
|
||||||
/// Handle to an internal Lua function.
|
/// Handle to an internal Lua function.
|
||||||
|
|
22
src/lib.rs
22
src/lib.rs
|
@ -44,36 +44,36 @@
|
||||||
extern crate failure;
|
extern crate failure;
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
|
||||||
mod ffi;
|
|
||||||
mod error;
|
mod error;
|
||||||
|
mod ffi;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod macros;
|
mod macros;
|
||||||
mod util;
|
|
||||||
mod value;
|
|
||||||
mod types;
|
|
||||||
mod lua;
|
|
||||||
mod conversion;
|
mod conversion;
|
||||||
|
mod function;
|
||||||
|
mod lua;
|
||||||
mod multi;
|
mod multi;
|
||||||
|
mod scope;
|
||||||
mod string;
|
mod string;
|
||||||
mod table;
|
mod table;
|
||||||
mod function;
|
|
||||||
mod thread;
|
mod thread;
|
||||||
|
mod types;
|
||||||
mod userdata;
|
mod userdata;
|
||||||
mod scope;
|
mod util;
|
||||||
|
mod value;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
pub use error::{Error, ExternalError, ExternalResult, Result};
|
pub use error::{Error, ExternalError, ExternalResult, Result};
|
||||||
pub use types::{Integer, LightUserData, Number, RegistryKey};
|
pub use function::Function;
|
||||||
|
pub use lua::Lua;
|
||||||
pub use multi::Variadic;
|
pub use multi::Variadic;
|
||||||
|
pub use scope::Scope;
|
||||||
pub use string::String;
|
pub use string::String;
|
||||||
pub use table::{Table, TablePairs, TableSequence};
|
pub use table::{Table, TablePairs, TableSequence};
|
||||||
pub use function::Function;
|
|
||||||
pub use thread::{Thread, ThreadStatus};
|
pub use thread::{Thread, ThreadStatus};
|
||||||
|
pub use types::{Integer, LightUserData, Number, RegistryKey};
|
||||||
pub use userdata::{AnyUserData, MetaMethod, UserData, UserDataMethods};
|
pub use userdata::{AnyUserData, MetaMethod, UserData, UserDataMethods};
|
||||||
pub use value::{FromLua, FromLuaMulti, MultiValue, Nil, ToLua, ToLuaMulti, Value};
|
pub use value::{FromLua, FromLuaMulti, MultiValue, Nil, ToLua, ToLuaMulti, Value};
|
||||||
pub use lua::Lua;
|
|
||||||
pub use scope::Scope;
|
|
||||||
|
|
||||||
pub mod prelude;
|
pub mod prelude;
|
||||||
|
|
32
src/lua.rs
32
src/lua.rs
|
@ -1,28 +1,29 @@
|
||||||
use std::{mem, ptr, str};
|
|
||||||
use std::sync::{Arc, Mutex};
|
|
||||||
use std::cell::{RefCell, UnsafeCell};
|
|
||||||
use std::ffi::CString;
|
|
||||||
use std::any::TypeId;
|
use std::any::TypeId;
|
||||||
use std::marker::PhantomData;
|
use std::cell::{RefCell, UnsafeCell};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use std::ffi::CString;
|
||||||
|
use std::marker::PhantomData;
|
||||||
use std::os::raw::{c_char, c_int, c_void};
|
use std::os::raw::{c_char, c_int, c_void};
|
||||||
|
use std::sync::{Arc, Mutex};
|
||||||
|
use std::{mem, ptr, str};
|
||||||
|
|
||||||
use libc;
|
use libc;
|
||||||
|
|
||||||
use ffi;
|
|
||||||
use error::{Error, Result};
|
use error::{Error, Result};
|
||||||
use util::{assert_stack, callback_error, check_stack, gc_guard, get_userdata, get_wrapped_error,
|
use ffi;
|
||||||
init_error_metatables, main_state, pop_error, protect_lua, protect_lua_closure,
|
use function::Function;
|
||||||
push_string, push_userdata, push_wrapped_error, safe_pcall, safe_xpcall,
|
use scope::Scope;
|
||||||
userdata_destructor, StackGuard};
|
|
||||||
use value::{FromLua, FromLuaMulti, MultiValue, Nil, ToLua, ToLuaMulti, Value};
|
|
||||||
use types::{Callback, Integer, LightUserData, LuaRef, Number, RegistryKey};
|
|
||||||
use string::String;
|
use string::String;
|
||||||
use table::Table;
|
use table::Table;
|
||||||
use function::Function;
|
|
||||||
use thread::Thread;
|
use thread::Thread;
|
||||||
|
use types::{Callback, Integer, LightUserData, LuaRef, Number, RegistryKey};
|
||||||
use userdata::{AnyUserData, MetaMethod, UserData, UserDataMethods};
|
use userdata::{AnyUserData, MetaMethod, UserData, UserDataMethods};
|
||||||
use scope::Scope;
|
use util::{
|
||||||
|
assert_stack, callback_error, check_stack, gc_guard, get_userdata, get_wrapped_error,
|
||||||
|
init_error_metatables, main_state, pop_error, protect_lua, protect_lua_closure, push_string,
|
||||||
|
push_userdata, push_wrapped_error, safe_pcall, safe_xpcall, userdata_destructor, StackGuard,
|
||||||
|
};
|
||||||
|
use value::{FromLua, FromLuaMulti, MultiValue, Nil, ToLua, ToLuaMulti, Value};
|
||||||
|
|
||||||
/// Top level Lua struct which holds the Lua state itself.
|
/// Top level Lua struct which holds the Lua state itself.
|
||||||
pub struct Lua {
|
pub struct Lua {
|
||||||
|
@ -285,7 +286,8 @@ impl Lua {
|
||||||
{
|
{
|
||||||
let func = RefCell::new(func);
|
let func = RefCell::new(func);
|
||||||
self.create_function(move |lua, args| {
|
self.create_function(move |lua, args| {
|
||||||
(&mut *func.try_borrow_mut()
|
(&mut *func
|
||||||
|
.try_borrow_mut()
|
||||||
.map_err(|_| Error::RecursiveMutCallback)?)(lua, args)
|
.map_err(|_| Error::RecursiveMutCallback)?)(lua, args)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
macro_rules! cstr {
|
macro_rules! cstr {
|
||||||
($s:expr) => (
|
($s:expr) => {
|
||||||
concat!($s, "\0") as *const str as *const [::std::os::raw::c_char] as *const ::std::os::raw::c_char
|
concat!($s, "\0") as *const str as *const [::std::os::raw::c_char]
|
||||||
);
|
as *const ::std::os::raw::c_char
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! abort {
|
macro_rules! abort {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use std::ops::{Deref, DerefMut};
|
|
||||||
use std::iter::FromIterator;
|
use std::iter::FromIterator;
|
||||||
|
use std::ops::{Deref, DerefMut};
|
||||||
use std::result::Result as StdResult;
|
use std::result::Result as StdResult;
|
||||||
|
|
||||||
use error::Result;
|
use error::Result;
|
||||||
use value::{FromLua, FromLuaMulti, MultiValue, Nil, ToLua, ToLuaMulti};
|
|
||||||
use lua::Lua;
|
use lua::Lua;
|
||||||
|
use value::{FromLua, FromLuaMulti, MultiValue, Nil, ToLua, ToLuaMulti};
|
||||||
|
|
||||||
/// Result is convertible to `MultiValue` following the common Lua idiom of returning the result
|
/// 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.
|
/// on success, or in the case of an error, returning `nil` and an error message.
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
//! Re-exports most types with an extra `Lua*` prefix to prevent name clashes.
|
//! Re-exports most types with an extra `Lua*` prefix to prevent name clashes.
|
||||||
|
|
||||||
pub use {AnyUserData as LuaAnyUserData, Error as LuaError, ExternalError as LuaExternalError,
|
pub use {
|
||||||
ExternalResult as LuaExternalResult, FromLua, FromLuaMulti, Function as LuaFunction,
|
AnyUserData as LuaAnyUserData, Error as LuaError, ExternalError as LuaExternalError,
|
||||||
Integer as LuaInteger, LightUserData as LuaLightUserData, Lua,
|
ExternalResult as LuaExternalResult, FromLua, FromLuaMulti, Function as LuaFunction,
|
||||||
MetaMethod as LuaMetaMethod, MultiValue as LuaMultiValue, Nil as LuaNil,
|
Integer as LuaInteger, LightUserData as LuaLightUserData, Lua, MetaMethod as LuaMetaMethod,
|
||||||
Number as LuaNumber, RegistryKey as LuaRegistryKey, Result as LuaResult,
|
MultiValue as LuaMultiValue, Nil as LuaNil, Number as LuaNumber, RegistryKey as LuaRegistryKey,
|
||||||
Scope as LuaScope, String as LuaString, Table as LuaTable, TablePairs as LuaTablePairs,
|
Result as LuaResult, Scope as LuaScope, String as LuaString, Table as LuaTable,
|
||||||
TableSequence as LuaTableSequence, Thread as LuaThread, ThreadStatus as LuaThreadStatus,
|
TablePairs as LuaTablePairs, TableSequence as LuaTableSequence, Thread as LuaThread,
|
||||||
ToLua, ToLuaMulti, UserData as LuaUserData, UserDataMethods as LuaUserDataMethods,
|
ThreadStatus as LuaThreadStatus, ToLua, ToLuaMulti, UserData as LuaUserData,
|
||||||
Value as LuaValue};
|
UserDataMethods as LuaUserDataMethods, Value as LuaValue,
|
||||||
|
};
|
||||||
|
|
20
src/scope.rs
20
src/scope.rs
|
@ -1,16 +1,16 @@
|
||||||
use std::mem;
|
|
||||||
use std::cell::RefCell;
|
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
|
use std::cell::RefCell;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
use std::mem;
|
||||||
|
|
||||||
use ffi;
|
|
||||||
use error::{Error, Result};
|
use error::{Error, Result};
|
||||||
|
use ffi;
|
||||||
|
use function::Function;
|
||||||
|
use lua::Lua;
|
||||||
|
use types::Callback;
|
||||||
|
use userdata::{AnyUserData, UserData};
|
||||||
use util::{assert_stack, take_userdata, StackGuard};
|
use util::{assert_stack, take_userdata, StackGuard};
|
||||||
use value::{FromLuaMulti, ToLuaMulti};
|
use value::{FromLuaMulti, ToLuaMulti};
|
||||||
use types::Callback;
|
|
||||||
use lua::Lua;
|
|
||||||
use function::Function;
|
|
||||||
use userdata::{AnyUserData, UserData};
|
|
||||||
|
|
||||||
/// Constructed by the [`Lua::scope`] method, allows temporarily passing to Lua userdata that is
|
/// Constructed by the [`Lua::scope`] method, allows temporarily passing to Lua userdata that is
|
||||||
/// !Send, and callbacks that are !Send and not 'static.
|
/// !Send, and callbacks that are !Send and not 'static.
|
||||||
|
@ -109,7 +109,8 @@ impl<'scope> Scope<'scope> {
|
||||||
{
|
{
|
||||||
let func = RefCell::new(func);
|
let func = RefCell::new(func);
|
||||||
self.create_function(move |lua, args| {
|
self.create_function(move |lua, args| {
|
||||||
(&mut *func.try_borrow_mut()
|
(&mut *func
|
||||||
|
.try_borrow_mut()
|
||||||
.map_err(|_| Error::RecursiveMutCallback)?)(lua, args)
|
.map_err(|_| Error::RecursiveMutCallback)?)(lua, args)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -148,7 +149,8 @@ impl<'scope> Drop for Scope<'scope> {
|
||||||
// userdata type into two phases. This is so that, in the event a userdata drop panics, we
|
// userdata type into two phases. This is so that, in the event a userdata drop panics, we
|
||||||
// can be sure that all of the userdata in Lua is actually invalidated.
|
// can be sure that all of the userdata in Lua is actually invalidated.
|
||||||
|
|
||||||
let to_drop = self.destructors
|
let to_drop = self
|
||||||
|
.destructors
|
||||||
.get_mut()
|
.get_mut()
|
||||||
.drain(..)
|
.drain(..)
|
||||||
.map(|destructor| destructor())
|
.map(|destructor| destructor())
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use std::{slice, str};
|
use std::{slice, str};
|
||||||
|
|
||||||
use ffi;
|
|
||||||
use error::{Error, Result};
|
use error::{Error, Result};
|
||||||
use util::{assert_stack, StackGuard};
|
use ffi;
|
||||||
use types::LuaRef;
|
use types::LuaRef;
|
||||||
|
use util::{assert_stack, StackGuard};
|
||||||
|
|
||||||
/// Handle to an internal Lua string.
|
/// Handle to an internal Lua string.
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::os::raw::c_int;
|
use std::os::raw::c_int;
|
||||||
|
|
||||||
use ffi;
|
|
||||||
use error::Result;
|
use error::Result;
|
||||||
use util::{assert_stack, protect_lua, protect_lua_closure, StackGuard};
|
use ffi;
|
||||||
use types::{Integer, LuaRef};
|
use types::{Integer, LuaRef};
|
||||||
|
use util::{assert_stack, protect_lua, protect_lua_closure, StackGuard};
|
||||||
use value::{FromLua, Nil, ToLua, Value};
|
use value::{FromLua, Nil, ToLua, Value};
|
||||||
|
|
||||||
/// Handle to an internal Lua table.
|
/// Handle to an internal Lua table.
|
||||||
|
|
156
src/tests/mod.rs
156
src/tests/mod.rs
|
@ -5,15 +5,17 @@ mod thread;
|
||||||
mod types;
|
mod types;
|
||||||
mod userdata;
|
mod userdata;
|
||||||
|
|
||||||
use std::{error, fmt};
|
|
||||||
use std::iter::FromIterator;
|
|
||||||
use std::rc::Rc;
|
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::sync::Arc;
|
use std::iter::FromIterator;
|
||||||
use std::panic::catch_unwind;
|
use std::panic::catch_unwind;
|
||||||
|
use std::rc::Rc;
|
||||||
|
use std::sync::Arc;
|
||||||
|
use std::{error, fmt};
|
||||||
|
|
||||||
use {Error, ExternalError, Function, Lua, Nil, Result, String, Table, UserData, UserDataMethods,
|
use {
|
||||||
Value, Variadic};
|
Error, ExternalError, Function, Lua, Nil, Result, String, Table, UserData, UserDataMethods,
|
||||||
|
Value, Variadic,
|
||||||
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_load() {
|
fn test_load() {
|
||||||
|
@ -51,8 +53,9 @@ fn test_exec() {
|
||||||
).unwrap();
|
).unwrap();
|
||||||
assert_eq!(globals.get::<_, String>("res").unwrap(), "foobar");
|
assert_eq!(globals.get::<_, String>("res").unwrap(), "foobar");
|
||||||
|
|
||||||
let module: Table = lua.exec(
|
let module: Table =
|
||||||
r#"
|
lua.exec(
|
||||||
|
r#"
|
||||||
local module = {}
|
local module = {}
|
||||||
|
|
||||||
function module.func()
|
function module.func()
|
||||||
|
@ -61,8 +64,8 @@ fn test_exec() {
|
||||||
|
|
||||||
return module
|
return module
|
||||||
"#,
|
"#,
|
||||||
None,
|
None,
|
||||||
).unwrap();
|
).unwrap();
|
||||||
assert!(module.contains_key("func").unwrap());
|
assert!(module.contains_key("func").unwrap());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
module
|
module
|
||||||
|
@ -214,9 +217,9 @@ fn test_error() {
|
||||||
None,
|
None,
|
||||||
).unwrap();
|
).unwrap();
|
||||||
|
|
||||||
let rust_error_function = lua.create_function(|_, ()| -> Result<()> {
|
let rust_error_function = lua
|
||||||
Err(TestError.to_lua_err())
|
.create_function(|_, ()| -> Result<()> { Err(TestError.to_lua_err()) })
|
||||||
}).unwrap();
|
.unwrap();
|
||||||
globals
|
globals
|
||||||
.set("rust_error_function", rust_error_function)
|
.set("rust_error_function", rust_error_function)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -281,9 +284,9 @@ fn test_error() {
|
||||||
"#,
|
"#,
|
||||||
None,
|
None,
|
||||||
)?;
|
)?;
|
||||||
let rust_panic_function = lua.create_function(|_, ()| -> Result<()> {
|
let rust_panic_function = lua
|
||||||
panic!("test_panic")
|
.create_function(|_, ()| -> Result<()> { panic!("test_panic") })
|
||||||
}).unwrap();
|
.unwrap();
|
||||||
globals.set("rust_panic_function", rust_panic_function)?;
|
globals.set("rust_panic_function", rust_panic_function)?;
|
||||||
|
|
||||||
let rust_panic = globals.get::<_, Function>("rust_panic")?;
|
let rust_panic = globals.get::<_, Function>("rust_panic")?;
|
||||||
|
@ -307,9 +310,9 @@ fn test_error() {
|
||||||
"#,
|
"#,
|
||||||
None,
|
None,
|
||||||
)?;
|
)?;
|
||||||
let rust_panic_function = lua.create_function(|_, ()| -> Result<()> {
|
let rust_panic_function = lua
|
||||||
panic!("test_panic")
|
.create_function(|_, ()| -> Result<()> { panic!("test_panic") })
|
||||||
}).unwrap();
|
.unwrap();
|
||||||
globals.set("rust_panic_function", rust_panic_function)?;
|
globals.set("rust_panic_function", rust_panic_function)?;
|
||||||
|
|
||||||
let rust_panic = globals.get::<_, Function>("rust_panic")?;
|
let rust_panic = globals.get::<_, Function>("rust_panic")?;
|
||||||
|
@ -327,12 +330,14 @@ fn test_result_conversions() {
|
||||||
let lua = Lua::new();
|
let lua = Lua::new();
|
||||||
let globals = lua.globals();
|
let globals = lua.globals();
|
||||||
|
|
||||||
let err = lua.create_function(|_, ()| {
|
let err =
|
||||||
Ok(Err::<String, _>(
|
lua.create_function(|_, ()| {
|
||||||
format_err!("only through failure can we succeed").to_lua_err(),
|
Ok(Err::<String, _>(
|
||||||
))
|
format_err!("only through failure can we succeed").to_lua_err(),
|
||||||
}).unwrap();
|
))
|
||||||
let ok = lua.create_function(|_, ()| Ok(Ok::<_, Error>("!".to_owned())))
|
}).unwrap();
|
||||||
|
let ok = lua
|
||||||
|
.create_function(|_, ()| Ok(Ok::<_, Error>("!".to_owned())))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
globals.set("err", err).unwrap();
|
globals.set("err", err).unwrap();
|
||||||
|
@ -389,12 +394,14 @@ fn test_pcall_xpcall() {
|
||||||
|
|
||||||
// Make sure that the return values from are correct on success
|
// Make sure that the return values from are correct on success
|
||||||
|
|
||||||
let (r, e) = lua.eval::<(bool, String)>("pcall(function(p) return p end, 'foo')", None)
|
let (r, e) = lua
|
||||||
|
.eval::<(bool, String)>("pcall(function(p) return p end, 'foo')", None)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert!(r);
|
assert!(r);
|
||||||
assert_eq!(e, "foo");
|
assert_eq!(e, "foo");
|
||||||
|
|
||||||
let (r, e) = lua.eval::<(bool, String)>("xpcall(function(p) return p end, print, 'foo')", None)
|
let (r, e) = lua
|
||||||
|
.eval::<(bool, String)>("xpcall(function(p) return p end, print, 'foo')", None)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert!(r);
|
assert!(r);
|
||||||
assert_eq!(e, "foo");
|
assert_eq!(e, "foo");
|
||||||
|
@ -444,23 +451,26 @@ fn test_recursive_mut_callback_error() {
|
||||||
let lua = Lua::new();
|
let lua = Lua::new();
|
||||||
|
|
||||||
let mut v = Some(Box::new(123));
|
let mut v = Some(Box::new(123));
|
||||||
let f = lua.create_function_mut::<_, (), _>(move |lua, mutate: bool| {
|
let f = lua
|
||||||
if mutate {
|
.create_function_mut::<_, (), _>(move |lua, mutate: bool| {
|
||||||
v = None;
|
if mutate {
|
||||||
} else {
|
v = None;
|
||||||
// Produce a mutable reference
|
} else {
|
||||||
let r = v.as_mut().unwrap();
|
// Produce a mutable reference
|
||||||
// Whoops, this will recurse into the function and produce another mutable reference!
|
let r = v.as_mut().unwrap();
|
||||||
lua.globals().get::<_, Function>("f")?.call::<_, ()>(true)?;
|
// Whoops, this will recurse into the function and produce another mutable reference!
|
||||||
println!("Should not get here, mutable aliasing has occurred!");
|
lua.globals().get::<_, Function>("f")?.call::<_, ()>(true)?;
|
||||||
println!("value at {:p}", r as *mut _);
|
println!("Should not get here, mutable aliasing has occurred!");
|
||||||
println!("value is {}", r);
|
println!("value at {:p}", r as *mut _);
|
||||||
}
|
println!("value is {}", r);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}).unwrap();
|
})
|
||||||
|
.unwrap();
|
||||||
lua.globals().set("f", f).unwrap();
|
lua.globals().set("f", f).unwrap();
|
||||||
match lua.globals()
|
match lua
|
||||||
|
.globals()
|
||||||
.get::<_, Function>("f")
|
.get::<_, Function>("f")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.call::<_, ()>(false)
|
.call::<_, ()>(false)
|
||||||
|
@ -516,10 +526,11 @@ fn test_named_registry_value() {
|
||||||
let lua = Lua::new();
|
let lua = Lua::new();
|
||||||
|
|
||||||
lua.set_named_registry_value::<i32>("test", 42).unwrap();
|
lua.set_named_registry_value::<i32>("test", 42).unwrap();
|
||||||
let f = lua.create_function(move |lua, ()| {
|
let f =
|
||||||
assert_eq!(lua.named_registry_value::<i32>("test")?, 42);
|
lua.create_function(move |lua, ()| {
|
||||||
Ok(())
|
assert_eq!(lua.named_registry_value::<i32>("test")?, 42);
|
||||||
}).unwrap();
|
Ok(())
|
||||||
|
}).unwrap();
|
||||||
|
|
||||||
f.call::<_, ()>(()).unwrap();
|
f.call::<_, ()>(()).unwrap();
|
||||||
|
|
||||||
|
@ -535,15 +546,16 @@ fn test_registry_value() {
|
||||||
let lua = Lua::new();
|
let lua = Lua::new();
|
||||||
|
|
||||||
let mut r = Some(lua.create_registry_value::<i32>(42).unwrap());
|
let mut r = Some(lua.create_registry_value::<i32>(42).unwrap());
|
||||||
let f = lua.create_function_mut(move |lua, ()| {
|
let f =
|
||||||
if let Some(r) = r.take() {
|
lua.create_function_mut(move |lua, ()| {
|
||||||
assert_eq!(lua.registry_value::<i32>(&r)?, 42);
|
if let Some(r) = r.take() {
|
||||||
lua.remove_registry_value(r).unwrap();
|
assert_eq!(lua.registry_value::<i32>(&r)?, 42);
|
||||||
} else {
|
lua.remove_registry_value(r).unwrap();
|
||||||
panic!();
|
} else {
|
||||||
}
|
panic!();
|
||||||
Ok(())
|
}
|
||||||
}).unwrap();
|
Ok(())
|
||||||
|
}).unwrap();
|
||||||
|
|
||||||
f.call::<_, ()>(()).unwrap();
|
f.call::<_, ()>(()).unwrap();
|
||||||
}
|
}
|
||||||
|
@ -628,7 +640,8 @@ fn scope_func() {
|
||||||
assert_eq!(rc.get(), 42);
|
assert_eq!(rc.get(), 42);
|
||||||
assert_eq!(Rc::strong_count(&rc), 1);
|
assert_eq!(Rc::strong_count(&rc), 1);
|
||||||
|
|
||||||
match lua.globals()
|
match lua
|
||||||
|
.globals()
|
||||||
.get::<_, Function>("bad")
|
.get::<_, Function>("bad")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.call::<_, ()>(())
|
.call::<_, ()>(())
|
||||||
|
@ -706,7 +719,8 @@ fn outer_lua_access() {
|
||||||
#[test]
|
#[test]
|
||||||
fn too_many_returns() {
|
fn too_many_returns() {
|
||||||
let lua = Lua::new();
|
let lua = Lua::new();
|
||||||
let f = lua.create_function(|_, ()| Ok(Variadic::from_iter(1..1000000)))
|
let f = lua
|
||||||
|
.create_function(|_, ()| Ok(Variadic::from_iter(1..1000000)))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert!(f.call::<_, Vec<u32>>(()).is_err());
|
assert!(f.call::<_, Vec<u32>>(()).is_err());
|
||||||
}
|
}
|
||||||
|
@ -729,9 +743,9 @@ fn too_many_arguments() {
|
||||||
fn too_many_recursions() {
|
fn too_many_recursions() {
|
||||||
let lua = Lua::new();
|
let lua = Lua::new();
|
||||||
|
|
||||||
let f = lua.create_function(move |lua, ()| {
|
let f = lua
|
||||||
lua.globals().get::<_, Function>("f")?.call::<_, ()>(())
|
.create_function(move |lua, ()| lua.globals().get::<_, Function>("f")?.call::<_, ()>(()))
|
||||||
}).unwrap();
|
.unwrap();
|
||||||
lua.globals().set("f", f).unwrap();
|
lua.globals().set("f", f).unwrap();
|
||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
|
@ -783,14 +797,15 @@ fn large_args() {
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let f: Function = lua.eval(
|
let f: Function =
|
||||||
r#"
|
lua.eval(
|
||||||
|
r#"
|
||||||
return function(...)
|
return function(...)
|
||||||
return c(...)
|
return c(...)
|
||||||
end
|
end
|
||||||
"#,
|
"#,
|
||||||
None,
|
None,
|
||||||
).unwrap();
|
).unwrap();
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
f.call::<_, usize>((0..100).collect::<Variadic<usize>>())
|
f.call::<_, usize>((0..100).collect::<Variadic<usize>>())
|
||||||
|
@ -803,12 +818,13 @@ fn large_args() {
|
||||||
fn large_args_ref() {
|
fn large_args_ref() {
|
||||||
let lua = Lua::new();
|
let lua = Lua::new();
|
||||||
|
|
||||||
let f = lua.create_function(|_, args: Variadic<String>| {
|
let f =
|
||||||
for i in 0..args.len() {
|
lua.create_function(|_, args: Variadic<String>| {
|
||||||
assert_eq!(args[i], i.to_string());
|
for i in 0..args.len() {
|
||||||
}
|
assert_eq!(args[i], i.to_string());
|
||||||
Ok(())
|
}
|
||||||
}).unwrap();
|
Ok(())
|
||||||
|
}).unwrap();
|
||||||
|
|
||||||
f.call::<_, ()>((0..100).map(|i| i.to_string()).collect::<Variadic<_>>())
|
f.call::<_, ()>((0..100).map(|i| i.to_string()).collect::<Variadic<_>>())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
|
@ -5,8 +5,10 @@ use {Error, Function, Lua, Result, Thread, ThreadStatus};
|
||||||
#[test]
|
#[test]
|
||||||
fn test_thread() {
|
fn test_thread() {
|
||||||
let lua = Lua::new();
|
let lua = Lua::new();
|
||||||
let thread = lua.create_thread(lua.eval::<Function>(
|
let thread =
|
||||||
r#"
|
lua.create_thread(
|
||||||
|
lua.eval::<Function>(
|
||||||
|
r#"
|
||||||
function (s)
|
function (s)
|
||||||
local sum = s
|
local sum = s
|
||||||
for i = 1,4 do
|
for i = 1,4 do
|
||||||
|
@ -15,9 +17,9 @@ fn test_thread() {
|
||||||
return sum
|
return sum
|
||||||
end
|
end
|
||||||
"#,
|
"#,
|
||||||
None,
|
None,
|
||||||
).unwrap())
|
).unwrap(),
|
||||||
.unwrap();
|
).unwrap();
|
||||||
|
|
||||||
assert_eq!(thread.status(), ThreadStatus::Resumable);
|
assert_eq!(thread.status(), ThreadStatus::Resumable);
|
||||||
assert_eq!(thread.resume::<_, i64>(0).unwrap(), 0);
|
assert_eq!(thread.resume::<_, i64>(0).unwrap(), 0);
|
||||||
|
@ -31,17 +33,19 @@ fn test_thread() {
|
||||||
assert_eq!(thread.resume::<_, i64>(4).unwrap(), 10);
|
assert_eq!(thread.resume::<_, i64>(4).unwrap(), 10);
|
||||||
assert_eq!(thread.status(), ThreadStatus::Unresumable);
|
assert_eq!(thread.status(), ThreadStatus::Unresumable);
|
||||||
|
|
||||||
let accumulate = lua.create_thread(lua.eval::<Function>(
|
let accumulate =
|
||||||
r#"
|
lua.create_thread(
|
||||||
|
lua.eval::<Function>(
|
||||||
|
r#"
|
||||||
function (sum)
|
function (sum)
|
||||||
while true do
|
while true do
|
||||||
sum = sum + coroutine.yield(sum)
|
sum = sum + coroutine.yield(sum)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
"#,
|
"#,
|
||||||
None,
|
None,
|
||||||
).unwrap())
|
).unwrap(),
|
||||||
.unwrap();
|
).unwrap();
|
||||||
|
|
||||||
for i in 0..4 {
|
for i in 0..4 {
|
||||||
accumulate.resume::<_, ()>(i).unwrap();
|
accumulate.resume::<_, ()>(i).unwrap();
|
||||||
|
@ -51,21 +55,23 @@ fn test_thread() {
|
||||||
assert!(accumulate.resume::<_, ()>("error").is_err());
|
assert!(accumulate.resume::<_, ()>("error").is_err());
|
||||||
assert_eq!(accumulate.status(), ThreadStatus::Error);
|
assert_eq!(accumulate.status(), ThreadStatus::Error);
|
||||||
|
|
||||||
let thread = lua.eval::<Thread>(
|
let thread =
|
||||||
r#"
|
lua.eval::<Thread>(
|
||||||
|
r#"
|
||||||
coroutine.create(function ()
|
coroutine.create(function ()
|
||||||
while true do
|
while true do
|
||||||
coroutine.yield(42)
|
coroutine.yield(42)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
"#,
|
"#,
|
||||||
None,
|
None,
|
||||||
).unwrap();
|
).unwrap();
|
||||||
assert_eq!(thread.status(), ThreadStatus::Resumable);
|
assert_eq!(thread.status(), ThreadStatus::Resumable);
|
||||||
assert_eq!(thread.resume::<_, i64>(()).unwrap(), 42);
|
assert_eq!(thread.resume::<_, i64>(()).unwrap(), 42);
|
||||||
|
|
||||||
let thread: Thread = lua.eval(
|
let thread: Thread =
|
||||||
r#"
|
lua.eval(
|
||||||
|
r#"
|
||||||
coroutine.create(function(arg)
|
coroutine.create(function(arg)
|
||||||
assert(arg == 42)
|
assert(arg == 42)
|
||||||
local yieldarg = coroutine.yield(123)
|
local yieldarg = coroutine.yield(123)
|
||||||
|
@ -73,8 +79,8 @@ fn test_thread() {
|
||||||
return 987
|
return 987
|
||||||
end)
|
end)
|
||||||
"#,
|
"#,
|
||||||
None,
|
None,
|
||||||
).unwrap();
|
).unwrap();
|
||||||
|
|
||||||
assert_eq!(thread.resume::<_, u32>(42).unwrap(), 123);
|
assert_eq!(thread.resume::<_, u32>(42).unwrap(), 123);
|
||||||
assert_eq!(thread.resume::<_, u32>(43).unwrap(), 987);
|
assert_eq!(thread.resume::<_, u32>(43).unwrap(), 987);
|
||||||
|
|
|
@ -131,8 +131,9 @@ fn test_gc_userdata() {
|
||||||
globals.set("userdata", MyUserdata { id: 123 }).unwrap();
|
globals.set("userdata", MyUserdata { id: 123 }).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
assert!(lua.eval::<()>(
|
assert!(
|
||||||
r#"
|
lua.eval::<()>(
|
||||||
|
r#"
|
||||||
local tbl = setmetatable({
|
local tbl = setmetatable({
|
||||||
userdata = userdata
|
userdata = userdata
|
||||||
}, { __gc = function(self)
|
}, { __gc = function(self)
|
||||||
|
@ -145,8 +146,9 @@ fn test_gc_userdata() {
|
||||||
collectgarbage("collect")
|
collectgarbage("collect")
|
||||||
hatch:access()
|
hatch:access()
|
||||||
"#,
|
"#,
|
||||||
None
|
None
|
||||||
).is_err());
|
).is_err()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use std::os::raw::c_int;
|
use std::os::raw::c_int;
|
||||||
|
|
||||||
use ffi;
|
|
||||||
use error::{Error, Result};
|
use error::{Error, Result};
|
||||||
use util::{assert_stack, check_stack, error_traceback, pop_error, StackGuard};
|
use ffi;
|
||||||
use types::LuaRef;
|
use types::LuaRef;
|
||||||
|
use util::{assert_stack, check_stack, error_traceback, pop_error, StackGuard};
|
||||||
use value::{FromLuaMulti, MultiValue, ToLuaMulti};
|
use value::{FromLuaMulti, MultiValue, ToLuaMulti};
|
||||||
|
|
||||||
/// Status of a Lua thread (or coroutine).
|
/// Status of a Lua thread (or coroutine).
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use std::{fmt, mem, ptr};
|
|
||||||
use std::os::raw::{c_int, c_void};
|
use std::os::raw::{c_int, c_void};
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
use std::{fmt, mem, ptr};
|
||||||
|
|
||||||
use ffi;
|
|
||||||
use error::Result;
|
use error::Result;
|
||||||
use value::MultiValue;
|
use ffi;
|
||||||
use lua::Lua;
|
use lua::Lua;
|
||||||
|
use value::MultiValue;
|
||||||
|
|
||||||
/// Type of Lua integer numbers.
|
/// Type of Lua integer numbers.
|
||||||
pub type Integer = ffi::lua_Integer;
|
pub type Integer = ffi::lua_Integer;
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
use std::cell::{Ref, RefCell, RefMut};
|
use std::cell::{Ref, RefCell, RefMut};
|
||||||
use std::marker::PhantomData;
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use std::marker::PhantomData;
|
||||||
use std::string::String as StdString;
|
use std::string::String as StdString;
|
||||||
|
|
||||||
use ffi;
|
|
||||||
use error::{Error, Result};
|
use error::{Error, Result};
|
||||||
use util::{assert_stack, get_userdata, StackGuard};
|
use ffi;
|
||||||
use types::{Callback, LuaRef};
|
|
||||||
use value::{FromLua, FromLuaMulti, ToLua, ToLuaMulti};
|
|
||||||
use lua::Lua;
|
use lua::Lua;
|
||||||
|
use types::{Callback, LuaRef};
|
||||||
|
use util::{assert_stack, get_userdata, StackGuard};
|
||||||
|
use value::{FromLua, FromLuaMulti, ToLua, ToLuaMulti};
|
||||||
|
|
||||||
/// Kinds of metamethods that can be overridden.
|
/// Kinds of metamethods that can be overridden.
|
||||||
///
|
///
|
||||||
|
@ -403,7 +403,8 @@ impl<'lua> AnyUserData<'lua> {
|
||||||
/// `UserDataTypeMismatch` if the userdata is not of type `T`.
|
/// `UserDataTypeMismatch` if the userdata is not of type `T`.
|
||||||
pub fn borrow_mut<T: UserData>(&self) -> Result<RefMut<T>> {
|
pub fn borrow_mut<T: UserData>(&self) -> Result<RefMut<T>> {
|
||||||
self.inspect(|cell| {
|
self.inspect(|cell| {
|
||||||
Ok(cell.try_borrow_mut()
|
Ok(cell
|
||||||
|
.try_borrow_mut()
|
||||||
.map_err(|_| Error::UserDataBorrowMutError)?)
|
.map_err(|_| Error::UserDataBorrowMutError)?)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
use std::{mem, ptr};
|
|
||||||
use std::sync::Arc;
|
|
||||||
use std::ffi::CStr;
|
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
|
use std::ffi::CStr;
|
||||||
use std::os::raw::{c_char, c_int, c_void};
|
use std::os::raw::{c_char, c_int, c_void};
|
||||||
use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe};
|
use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe};
|
||||||
|
use std::sync::Arc;
|
||||||
|
use std::{mem, ptr};
|
||||||
|
|
||||||
use ffi;
|
|
||||||
use error::{Error, Result};
|
use error::{Error, Result};
|
||||||
|
use ffi;
|
||||||
|
|
||||||
// Checks that Lua has enough free stack space for future stack operations. On failure, this will
|
// Checks that Lua has enough free stack space for future stack operations. On failure, this will
|
||||||
// panic with an internal error message.
|
// panic with an internal error message.
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
use std::{slice, str, vec};
|
|
||||||
use std::iter::{self, FromIterator};
|
use std::iter::{self, FromIterator};
|
||||||
|
use std::{slice, str, vec};
|
||||||
|
|
||||||
use error::{Error, Result};
|
use error::{Error, Result};
|
||||||
use types::{Integer, LightUserData, Number};
|
use function::Function;
|
||||||
|
use lua::Lua;
|
||||||
use string::String;
|
use string::String;
|
||||||
use table::Table;
|
use table::Table;
|
||||||
use function::Function;
|
|
||||||
use thread::Thread;
|
use thread::Thread;
|
||||||
|
use types::{Integer, LightUserData, Number};
|
||||||
use userdata::AnyUserData;
|
use userdata::AnyUserData;
|
||||||
use lua::Lua;
|
|
||||||
|
|
||||||
/// A dynamically typed Lua value. The `String`, `Table`, `Function`, `Thread`, and `UserData`
|
/// A dynamically typed Lua value. The `String`, `Table`, `Function`, `Thread`, and `UserData`
|
||||||
/// variants contain handle types into the internal Lua state. It is a logic error to mix handle
|
/// variants contain handle types into the internal Lua state. It is a logic error to mix handle
|
||||||
|
|
Loading…
Reference in New Issue