diff --git a/rust-hl-lua/Cargo.toml b/rust-hl-lua/Cargo.toml index 913e381..8cb1d14 100644 --- a/rust-hl-lua/Cargo.toml +++ b/rust-hl-lua/Cargo.toml @@ -3,3 +3,4 @@ name = "rust-hl-lua" version = "0.1.0" authors = [ "pierre.krieger1708@gmail.com" ] +license = "MIT" diff --git a/rust-hl-lua/src/lib.rs b/rust-hl-lua/src/lib.rs index c1d9247..d4a233a 100644 --- a/rust-hl-lua/src/lib.rs +++ b/rust-hl-lua/src/lib.rs @@ -1,7 +1,4 @@ #![crate_name = "rust-hl-lua"] -#![crate_type = "lib"] -#![comment = "Lua bindings for Rust"] -#![license = "MIT"] #![feature(macro_rules)] #![feature(unsafe_destructor)] @@ -218,7 +215,7 @@ impl<'lua> Lua<'lua> { /// Loads the value of a global variable. #[unstable] pub fn load<'a, I: Str, V: ConsumeRead<'a, Lua<'lua>>>(&'a mut self, index: I) -> Option { - unsafe { ffi::lua_getglobal(self.lua, index.as_slice().to_c_str().unwrap()); } + unsafe { ffi::lua_getglobal(self.lua, index.as_slice().to_c_str().into_inner()); } ConsumeRead::read_from_variable(LoadedVariable { lua: self, size: 1 }).ok() } @@ -231,7 +228,7 @@ impl<'lua> Lua<'lua> { /// Reads the value of a global variable by copying it. #[unstable] pub fn get>>(&mut self, index: I) -> Option { - unsafe { ffi::lua_getglobal(self.lua, index.as_slice().to_c_str().unwrap()); } + unsafe { ffi::lua_getglobal(self.lua, index.as_slice().to_c_str().into_inner()); } CopyRead::read_from_lua(self, -1) } @@ -239,7 +236,7 @@ impl<'lua> Lua<'lua> { #[unstable] pub fn set>>(&mut self, index: I, value: V) { value.push_to_lua(self); - unsafe { ffi::lua_setglobal(self.lua, index.as_slice().to_c_str().unwrap()); } + unsafe { ffi::lua_setglobal(self.lua, index.as_slice().to_c_str().into_inner()); } } #[unstable] diff --git a/rust-hl-lua/src/rust_tables.rs b/rust-hl-lua/src/rust_tables.rs index 38cc757..03cd5d3 100644 --- a/rust-hl-lua/src/rust_tables.rs +++ b/rust-hl-lua/src/rust_tables.rs @@ -3,7 +3,6 @@ use super::Push; use HasLua; use std::collections::{HashMap, HashSet}; -use std::iter::Repeat; use collections::hash::Hash; fn push_iter, I: Iterator>(lua: &mut L, iterator: I) -> uint { @@ -69,6 +68,7 @@ impl + Eq + Hash, V: Push> Push for HashMap { impl + Eq + Hash> Push for HashSet { fn push_to_lua(self, lua: &mut L) -> uint { - push_rec_iter(lua, self.into_iter().zip(Repeat::new(true))) + use std::iter; + push_rec_iter(lua, self.into_iter().zip(iter::repeat(true))) } } diff --git a/rust-hl-lua/src/values.rs b/rust-hl-lua/src/values.rs index 2a006ce..a9e4393 100644 --- a/rust-hl-lua/src/values.rs +++ b/rust-hl-lua/src/values.rs @@ -116,7 +116,7 @@ numeric_impl!(f64) impl Push for String { fn push_to_lua(self, lua: &mut L) -> uint { - unsafe { ffi::lua_pushstring(lua.use_lua(), self.to_c_str().unwrap()) }; + unsafe { ffi::lua_pushstring(lua.use_lua(), self.to_c_str().into_inner()) }; 1 } } @@ -147,7 +147,7 @@ impl Index for String { impl<'str, L: HasLua> Push for &'str str { fn push_to_lua(self, lua: &mut L) -> uint { - unsafe { ffi::lua_pushstring(lua.use_lua(), self.to_c_str().unwrap()) } + unsafe { ffi::lua_pushstring(lua.use_lua(), self.to_c_str().into_inner()) } 1 } } diff --git a/rust-hl-lua/tests/anyvalue_tests.rs b/rust-hl-lua/tests/anyvalue_tests.rs index 7a7eec5..ca508a3 100644 --- a/rust-hl-lua/tests/anyvalue_tests.rs +++ b/rust-hl-lua/tests/anyvalue_tests.rs @@ -1,6 +1,6 @@ extern crate "rust-hl-lua" as lua; use lua::Lua; -use lua::any::{AnyLuaValue,LuaNumber, LuaString, LuaBoolean}; +use lua::any::AnyLuaValue; #[test] fn read_numbers() { @@ -10,10 +10,10 @@ fn read_numbers() { lua.set("b", 3.5f32); let x: AnyLuaValue = lua.get("a").unwrap(); - assert_eq!(x, LuaNumber(-2.0)); + assert_eq!(x, AnyLuaValue::LuaNumber(-2.0)); let y: AnyLuaValue = lua.get("b").unwrap(); - assert_eq!(y, LuaNumber(3.5)); + assert_eq!(y, AnyLuaValue::LuaNumber(3.5)); } #[test] @@ -25,13 +25,13 @@ fn read_strings() { lua.set("c", "false"); let x: AnyLuaValue = lua.get("a").unwrap(); - assert_eq!(x, LuaString("hello".to_string())); + assert_eq!(x, AnyLuaValue::LuaString("hello".to_string())); let y: AnyLuaValue = lua.get("b").unwrap(); - assert_eq!(y, LuaString("3x".to_string())); + assert_eq!(y, AnyLuaValue::LuaString("3x".to_string())); let z: AnyLuaValue = lua.get("c").unwrap(); - assert_eq!(z, LuaString("false".to_string())); + assert_eq!(z, AnyLuaValue::LuaString("false".to_string())); } #[test] @@ -42,17 +42,17 @@ fn read_booleans() { lua.set("b", false); let x: AnyLuaValue = lua.get("a").unwrap(); - assert_eq!(x, LuaBoolean(true)); + assert_eq!(x, AnyLuaValue::LuaBoolean(true)); let y: AnyLuaValue = lua.get("b").unwrap(); - assert_eq!(y, LuaBoolean(false)); + assert_eq!(y, AnyLuaValue::LuaBoolean(false)); } #[test] fn push_numbers() { let mut lua = Lua::new(); - lua.set("a", LuaNumber(3.0)); + lua.set("a", AnyLuaValue::LuaNumber(3.0)); let x: int = lua.get("a").unwrap(); assert_eq!(x, 3); @@ -62,7 +62,7 @@ fn push_numbers() { fn push_strings() { let mut lua = Lua::new(); - lua.set("a", LuaString("hello".to_string())); + lua.set("a", AnyLuaValue::LuaString("hello".to_string())); let x: String = lua.get("a").unwrap(); assert_eq!(x.as_slice(), "hello"); @@ -72,7 +72,7 @@ fn push_strings() { fn push_booleans() { let mut lua = Lua::new(); - lua.set("a", LuaBoolean(true)); + lua.set("a", AnyLuaValue::LuaBoolean(true)); let x: bool = lua.get("a").unwrap(); assert_eq!(x, true); diff --git a/rust-hl-lua/tests/functions_write_tests.rs b/rust-hl-lua/tests/functions_write_tests.rs index fee68ca..ec2520d 100644 --- a/rust-hl-lua/tests/functions_write_tests.rs +++ b/rust-hl-lua/tests/functions_write_tests.rs @@ -41,7 +41,7 @@ fn wrong_arguments_types() { lua.set("add", add); match lua.execute::("return add(3, \"hello\")") { - Err(lua::ExecutionError(_)) => (), + Err(lua::LuaError::ExecutionError(_)) => (), _ => panic!() } } @@ -54,7 +54,7 @@ fn return_result() { lua.set("always_fails", always_fails); match lua.execute::<()>("always_fails()") { - Err(lua::ExecutionError(_)) => (), + Err(lua::LuaError::ExecutionError(_)) => (), _ => panic!() } } diff --git a/rust-hl-lua/tests/lua_tables_tests.rs b/rust-hl-lua/tests/lua_tables_tests.rs index 161a040..ec8a992 100644 --- a/rust-hl-lua/tests/lua_tables_tests.rs +++ b/rust-hl-lua/tests/lua_tables_tests.rs @@ -1,5 +1,5 @@ extern crate "rust-hl-lua" as lua; -use lua::{Lua, LuaTable}; +use lua::Lua; #[test] fn iterable() { @@ -29,8 +29,8 @@ fn iterable_multipletimes() { let mut table = lua.load_table("a").unwrap(); for _ in range(0u, 10) { - let tableContent: Vec> = table.iter().collect(); - assert_eq!(tableContent, vec!( Some((1,9)), Some((2,8)), Some((3,7)) )); + let table_content: Vec> = table.iter().collect(); + assert_eq!(table_content, vec!( Some((1,9)), Some((2,8)), Some((3,7)) )); } }