auto formatting

This commit is contained in:
kyren 2017-12-16 17:46:32 -05:00
parent bfb6111e0a
commit ad23fe83e0
3 changed files with 29 additions and 34 deletions

View File

@ -72,12 +72,11 @@ impl Lua {
check_stack(self.state, 1); check_stack(self.state, 1);
match if let Some(name) = name { match if let Some(name) = name {
let name = CString::new(name.to_owned()).map_err(|e| { let name =
Error::ToLuaConversionError { CString::new(name.to_owned()).map_err(|e| Error::ToLuaConversionError {
from: "&str", from: "&str",
to: "string", to: "string",
message: Some(e.to_string()), message: Some(e.to_string()),
}
})?; })?;
ffi::luaL_loadbuffer( ffi::luaL_loadbuffer(
self.state, self.state,

View File

@ -35,12 +35,10 @@ impl<'lua> String<'lua> {
/// # } /// # }
/// ``` /// ```
pub fn to_str(&self) -> Result<&str> { pub fn to_str(&self) -> Result<&str> {
str::from_utf8(self.as_bytes()).map_err(|e| { str::from_utf8(self.as_bytes()).map_err(|e| Error::FromLuaConversionError {
Error::FromLuaConversionError {
from: "string", from: "string",
to: "&str", to: "&str",
message: Some(e.to_string()), message: Some(e.to_string()),
}
}) })
} }

View File

@ -152,8 +152,7 @@ mod tests {
#[test] #[test]
fn test_thread() { fn test_thread() {
let lua = Lua::new(); let lua = Lua::new();
let thread = lua.create_thread( let thread = lua.create_thread(lua.eval::<Function>(
lua.eval::<Function>(
r#" r#"
function (s) function (s)
local sum = s local sum = s
@ -164,8 +163,8 @@ mod tests {
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);
@ -179,8 +178,7 @@ mod tests {
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( let accumulate = lua.create_thread(lua.eval::<Function>(
lua.eval::<Function>(
r#" r#"
function (sum) function (sum)
while true do while true do
@ -189,8 +187,8 @@ mod tests {
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();