cargo fmt

This commit is contained in:
kyren 2018-09-24 22:13:42 -04:00
parent 70b67052c9
commit 6a5ec6b387
5 changed files with 39 additions and 46 deletions

View file

@ -58,8 +58,8 @@ fn call_add_function(c: &mut Criterion) {
|| {
let lua = Lua::new();
let f = {
let f: LuaFunction =
lua.eval(
let f: LuaFunction = lua
.eval(
r#"
function(a, b, c)
return a + b + c
@ -94,8 +94,8 @@ fn call_add_callback(c: &mut Criterion) {
.create_function(|_, (a, b, c): (i64, i64, i64)| Ok(a + b + c))
.unwrap();
lua.globals().set("callback", c).unwrap();
let f: LuaFunction =
lua.eval(
let f: LuaFunction = lua
.eval(
r#"
function()
for i = 1,10 do
@ -126,13 +126,13 @@ fn call_append_callback(c: &mut Criterion) {
|| {
let lua = Lua::new();
let f = {
let c: LuaFunction =
lua.create_function(|_, (a, b): (LuaString, LuaString)| {
let c: LuaFunction = lua
.create_function(|_, (a, b): (LuaString, LuaString)| {
Ok(format!("{}{}", a.to_str()?, b.to_str()?))
}).unwrap();
lua.globals().set("callback", c).unwrap();
let f: LuaFunction =
lua.eval(
let f: LuaFunction = lua
.eval(
r#"
function()
for _ = 1,10 do

View file

@ -16,8 +16,7 @@ fn scope_func() {
.create_function(move |_, ()| {
r.set(42);
Ok(())
})
.unwrap();
}).unwrap();
lua.globals().set("bad", f.clone()).unwrap();
f.call::<_, ()>(()).unwrap();
assert_eq!(Rc::strong_count(&rc), 2);
@ -56,8 +55,7 @@ fn scope_drop() {
scope
.create_static_userdata(MyUserdata(rc.clone()))
.unwrap(),
)
.unwrap();
).unwrap();
assert_eq!(Rc::strong_count(&rc), 2);
});
assert_eq!(Rc::strong_count(&rc), 1);
@ -78,8 +76,7 @@ fn scope_capture() {
.create_function_mut(|_, ()| {
i = 42;
Ok(())
})
.unwrap()
}).unwrap()
.call::<_, ()>(())
.unwrap();
});
@ -95,8 +92,7 @@ fn outer_lua_access() {
.create_function_mut(|_, ()| {
table.set("a", "b").unwrap();
Ok(())
})
.unwrap()
}).unwrap()
.call::<_, ()>(())
.unwrap();
});
@ -125,8 +121,8 @@ fn scope_userdata_methods() {
let i = Cell::new(42);
lua.scope(|scope| {
let f: Function =
lua.eval(
let f: Function = lua
.eval(
r#"
function(u)
u:inc()
@ -165,8 +161,8 @@ fn scope_userdata_functions() {
}
let lua = Lua::new();
let f =
lua.exec::<Function>(
let f = lua
.exec::<Function>(
r#"
i = 0
return function(u)

View file

@ -88,8 +88,7 @@ fn test_table() {
.set(
"table4",
lua.create_sequence_from(vec![1, 2, 3, 4, 5]).unwrap(),
)
.unwrap();
).unwrap();
let table4 = globals.get::<_, Table>("table4").unwrap();
assert_eq!(
table4.pairs().collect::<Result<Vec<(i64, i64)>>>().unwrap(),
@ -132,8 +131,7 @@ fn test_metatable() {
.set(
"__index",
lua.create_function(|_, ()| Ok("index_value")).unwrap(),
)
.unwrap();
).unwrap();
table.set_metatable(Some(metatable));
assert_eq!(table.get::<_, String>("any_key").unwrap(), "index_value");
match table.raw_get::<_, Value>("any_key").unwrap() {

View file

@ -47,8 +47,8 @@ fn test_exec() {
).unwrap();
assert_eq!(globals.get::<_, String>("res").unwrap(), "foobar");
let module: Table =
lua.exec(
let module: Table = lua
.exec(
r#"
local module = {}
@ -324,8 +324,8 @@ fn test_result_conversions() {
let lua = Lua::new();
let globals = lua.globals();
let err =
lua.create_function(|_, ()| {
let err = lua
.create_function(|_, ()| {
Ok(Err::<String, _>(
err_msg("only through failure can we succeed").to_lua_err(),
))
@ -520,8 +520,8 @@ fn test_named_registry_value() {
let lua = Lua::new();
lua.set_named_registry_value::<i32>("test", 42).unwrap();
let f =
lua.create_function(move |lua, ()| {
let f = lua
.create_function(move |lua, ()| {
assert_eq!(lua.named_registry_value::<i32>("test")?, 42);
Ok(())
}).unwrap();
@ -540,8 +540,8 @@ fn test_registry_value() {
let lua = Lua::new();
let mut r = Some(lua.create_registry_value::<i32>(42).unwrap());
let f =
lua.create_function_mut(move |lua, ()| {
let f = lua
.create_function_mut(move |lua, ()| {
if let Some(r) = r.take() {
assert_eq!(lua.registry_value::<i32>(&r)?, 42);
lua.remove_registry_value(r).unwrap();
@ -692,11 +692,10 @@ fn large_args() {
}
Ok(s)
}).unwrap(),
)
.unwrap();
).unwrap();
let f: Function =
lua.eval(
let f: Function = lua
.eval(
r#"
return function(...)
return c(...)
@ -716,8 +715,8 @@ fn large_args() {
fn large_args_ref() {
let lua = Lua::new();
let f =
lua.create_function(|_, args: Variadic<String>| {
let f = lua
.create_function(|_, args: Variadic<String>| {
for i in 0..args.len() {
assert_eq!(args[i], i.to_string());
}

View file

@ -7,8 +7,8 @@ use rlua::{Error, Function, Lua, Result, Thread, ThreadStatus};
#[test]
fn test_thread() {
let lua = Lua::new();
let thread =
lua.create_thread(
let thread = lua
.create_thread(
lua.eval::<Function>(
r#"
function (s)
@ -35,8 +35,8 @@ fn test_thread() {
assert_eq!(thread.resume::<_, i64>(4).unwrap(), 10);
assert_eq!(thread.status(), ThreadStatus::Unresumable);
let accumulate =
lua.create_thread(
let accumulate = lua
.create_thread(
lua.eval::<Function>(
r#"
function (sum)
@ -57,8 +57,8 @@ fn test_thread() {
assert!(accumulate.resume::<_, ()>("error").is_err());
assert_eq!(accumulate.status(), ThreadStatus::Error);
let thread =
lua.eval::<Thread>(
let thread = lua
.eval::<Thread>(
r#"
coroutine.create(function ()
while true do
@ -71,8 +71,8 @@ fn test_thread() {
assert_eq!(thread.status(), ThreadStatus::Resumable);
assert_eq!(thread.resume::<_, i64>(()).unwrap(), 42);
let thread: Thread =
lua.eval(
let thread: Thread = lua
.eval(
r#"
coroutine.create(function(arg)
assert(arg == 42)