auto formatting
This commit is contained in:
parent
bfb6111e0a
commit
ad23fe83e0
|
@ -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,
|
||||
|
|
|
@ -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()),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -152,20 +152,19 @@ mod tests {
|
|||
#[test]
|
||||
fn test_thread() {
|
||||
let lua = Lua::new();
|
||||
let thread = lua.create_thread(
|
||||
lua.eval::<Function>(
|
||||
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::<Function>(
|
||||
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::<Function>(
|
||||
r#"
|
||||
function (sum)
|
||||
while true do
|
||||
sum = sum + coroutine.yield(sum)
|
||||
end
|
||||
let accumulate = lua.create_thread(lua.eval::<Function>(
|
||||
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();
|
||||
|
|
Loading…
Reference in New Issue