auto formatting
This commit is contained in:
parent
bfb6111e0a
commit
ad23fe83e0
|
@ -72,12 +72,11 @@ 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,
|
||||
|
|
|
@ -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 {
|
||||
str::from_utf8(self.as_bytes()).map_err(|e| Error::FromLuaConversionError {
|
||||
from: "string",
|
||||
to: "&str",
|
||||
message: Some(e.to_string()),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -152,8 +152,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_thread() {
|
||||
let lua = Lua::new();
|
||||
let thread = lua.create_thread(
|
||||
lua.eval::<Function>(
|
||||
let thread = lua.create_thread(lua.eval::<Function>(
|
||||
r#"
|
||||
function (s)
|
||||
local sum = s
|
||||
|
@ -164,8 +163,8 @@ mod tests {
|
|||
end
|
||||
"#,
|
||||
None,
|
||||
).unwrap(),
|
||||
).unwrap();
|
||||
).unwrap())
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(thread.status(), ThreadStatus::Resumable);
|
||||
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.status(), ThreadStatus::Unresumable);
|
||||
|
||||
let accumulate = lua.create_thread(
|
||||
lua.eval::<Function>(
|
||||
let accumulate = lua.create_thread(lua.eval::<Function>(
|
||||
r#"
|
||||
function (sum)
|
||||
while true do
|
||||
|
@ -189,8 +187,8 @@ mod tests {
|
|||
end
|
||||
"#,
|
||||
None,
|
||||
).unwrap(),
|
||||
).unwrap();
|
||||
).unwrap())
|
||||
.unwrap();
|
||||
|
||||
for i in 0..4 {
|
||||
accumulate.resume::<_, ()>(i).unwrap();
|
||||
|
|
Loading…
Reference in New Issue