Skip to content

Commit 8518f37

Browse files
committed
cargo +nightly fmt
1 parent de25d51 commit 8518f37

4 files changed

Lines changed: 28 additions & 14 deletions

File tree

examples/async_http_client.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ impl UserData for BodyReader {
1414
// Every call returns a next chunk
1515
methods.add_async_method_mut("read", |lua, mut reader, ()| async move {
1616
if let Some(bytes) = reader.0.frame().await
17-
&& let Some(bytes) = bytes.into_lua_err()?.data_ref() {
18-
return Some(lua.create_string(bytes)).transpose();
19-
}
17+
&& let Some(bytes) = bytes.into_lua_err()?.data_ref()
18+
{
19+
return Some(lua.create_string(bytes)).transpose();
20+
}
2021
Ok(None)
2122
});
2223
}

src/state/raw.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,10 +401,9 @@ impl RawLua {
401401
},
402402
);
403403
#[cfg(feature = "luau-jit")]
404-
if status == ffi::LUA_OK
405-
&& (*self.extra.get()).enable_jit && ffi::luau_codegen_supported() != 0 {
406-
ffi::luau_codegen_compile(state, -1);
407-
}
404+
if status == ffi::LUA_OK && (*self.extra.get()).enable_jit && ffi::luau_codegen_supported() != 0 {
405+
ffi::luau_codegen_compile(state, -1);
406+
}
408407
status
409408
}
410409

tests/serde.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,19 @@ fn test_serialize_failure() -> Result<(), Box<dyn StdError>> {
109109
let lua = Lua::new();
110110

111111
let ud = Value::UserData(lua.create_userdata(MyUserData(123))?);
112-
if let Ok(v) = serde_json::to_value(&ud) { panic!("expected serialization error, got {}", v) }
112+
if let Ok(v) = serde_json::to_value(&ud) {
113+
panic!("expected serialization error, got {}", v)
114+
}
113115

114116
let func = lua.create_function(|_, _: ()| Ok(()))?;
115-
if let Ok(v) = serde_json::to_value(Value::Function(func.clone())) { panic!("expected serialization error, got {}", v) }
117+
if let Ok(v) = serde_json::to_value(Value::Function(func.clone())) {
118+
panic!("expected serialization error, got {}", v)
119+
}
116120

117121
let thr = lua.create_thread(func)?;
118-
if let Ok(v) = serde_json::to_value(Value::Thread(thr)) { panic!("expected serialization error, got {}", v) }
122+
if let Ok(v) = serde_json::to_value(Value::Thread(thr)) {
123+
panic!("expected serialization error, got {}", v)
124+
}
119125

120126
Ok(())
121127
}

tests/tests.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,9 @@ fn test_panic() -> Result<()> {
448448
)
449449
.eval::<Value>()?;
450450
Ok(())
451-
})) { panic!("no panic was detected") };
451+
})) {
452+
panic!("no panic was detected")
453+
};
452454

453455
assert!(lua.globals().get::<Value>("err")? == Value::Nil);
454456
match lua.load("tostring(err)").exec() {
@@ -917,16 +919,22 @@ fn test_application_data() -> Result<()> {
917919

918920
// Insert of new data or removal should fail now
919921
assert!(lua.try_set_app_data::<i32>(123).is_err());
920-
if catch_unwind(AssertUnwindSafe(|| lua.set_app_data::<i32>(123))).is_ok() { panic!("expected panic") }
921-
if catch_unwind(AssertUnwindSafe(|| lua.remove_app_data::<i32>())).is_ok() { panic!("expected panic") }
922+
if catch_unwind(AssertUnwindSafe(|| lua.set_app_data::<i32>(123))).is_ok() {
923+
panic!("expected panic")
924+
}
925+
if catch_unwind(AssertUnwindSafe(|| lua.remove_app_data::<i32>())).is_ok() {
926+
panic!("expected panic")
927+
}
922928

923929
// Check display and debug impls
924930
assert_eq!(format!("{s}"), "test1");
925931
assert_eq!(format!("{s:?}"), "\"test1\"");
926932

927933
// Borrowing immutably and mutably of the same type is not allowed
928934
assert!(lua.try_app_data_mut::<&str>().is_err());
929-
if let Ok(_) = catch_unwind(AssertUnwindSafe(|| lua.app_data_mut::<&str>().unwrap())) { panic!("expected panic") }
935+
if let Ok(_) = catch_unwind(AssertUnwindSafe(|| lua.app_data_mut::<&str>().unwrap())) {
936+
panic!("expected panic")
937+
}
930938
assert!(lua.try_app_data_ref::<Vec<&str>>().is_err());
931939
drop((s, v));
932940

0 commit comments

Comments
 (0)