diff --git a/src/lua.rs b/src/lua.rs index 74bc76b..e003a2b 100644 --- a/src/lua.rs +++ b/src/lua.rs @@ -72,13 +72,12 @@ impl Lua { check_stack(self.state, 1); match if let Some(name) = name { - let name = CString::new(name.to_owned()).map_err(|e| { - Error::ToLuaConversionError { + let name = + CString::new(name.to_owned()).map_err(|e| Error::ToLuaConversionError { from: "&str", to: "string", message: Some(e.to_string()), - } - })?; + })?; ffi::luaL_loadbuffer( self.state, source.as_ptr() as *const c_char, diff --git a/src/string.rs b/src/string.rs index bfc7231..a205dde 100644 --- a/src/string.rs +++ b/src/string.rs @@ -35,12 +35,10 @@ impl<'lua> String<'lua> { /// # } /// ``` pub fn to_str(&self) -> Result<&str> { - str::from_utf8(self.as_bytes()).map_err(|e| { - Error::FromLuaConversionError { - from: "string", - to: "&str", - message: Some(e.to_string()), - } + str::from_utf8(self.as_bytes()).map_err(|e| Error::FromLuaConversionError { + from: "string", + to: "&str", + message: Some(e.to_string()), }) } diff --git a/src/thread.rs b/src/thread.rs index 83eb994..59ab2e7 100644 --- a/src/thread.rs +++ b/src/thread.rs @@ -152,20 +152,19 @@ mod tests { #[test] fn test_thread() { let lua = Lua::new(); - let thread = lua.create_thread( - lua.eval::( - r#" - function (s) - local sum = s - for i = 1,4 do - sum = sum + coroutine.yield(sum) - end - return sum + let thread = lua.create_thread(lua.eval::( + r#" + function (s) + local sum = s + for i = 1,4 do + sum = sum + coroutine.yield(sum) end - "#, - None, - ).unwrap(), - ).unwrap(); + return sum + end + "#, + None, + ).unwrap()) + .unwrap(); assert_eq!(thread.status(), ThreadStatus::Resumable); assert_eq!(thread.resume::<_, i64>(0).unwrap(), 0); @@ -179,18 +178,17 @@ mod tests { assert_eq!(thread.resume::<_, i64>(4).unwrap(), 10); assert_eq!(thread.status(), ThreadStatus::Unresumable); - let accumulate = lua.create_thread( - lua.eval::( - r#" - function (sum) - while true do - sum = sum + coroutine.yield(sum) - end + let accumulate = lua.create_thread(lua.eval::( + r#" + function (sum) + while true do + sum = sum + coroutine.yield(sum) end - "#, - None, - ).unwrap(), - ).unwrap(); + end + "#, + None, + ).unwrap()) + .unwrap(); for i in 0..4 { accumulate.resume::<_, ()>(i).unwrap();