let
binding is redundant31 .unwrap();
32 let test: String = cmd("GET").arg("test").query_async(&mut conn).await.unwrap();
33 assert_eq!(test, "test");
34 let _: () = cmd("DEL").arg("test").query_async(&mut conn).await.unwrap();35
36 // set the pool as the global pool
37 crate::REDIS_POOL
let
binding is redundant23
24 // test the pool by setting a key and getting it, then deleting it
25 let mut conn = pool.get().await.unwrap();
26 let _: () = cmd("SET")27 .arg("test")28 .arg("test")29 .query_async(&mut conn)30 .await31 .unwrap();32 let test: String = cmd("GET").arg("test").query_async(&mut conn).await.unwrap();
33 assert_eq!(test, "test");
34 let _: () = cmd("DEL").arg("test").query_async(&mut conn).await.unwrap();
The ()
type, also called “unit”, has exactly one value ()
, and is used when there is no other meaningful value that could be returned. It is most commonly seen implicitly: functions without a ->
implicitly have return type ()
, that is, these are equivalent:
fn foo() {}
// vs,
fn foo() -> () {}
Hence explicitly ignoring values of unit type is redundant.
fn foo() {}
fn main() {
let _ = (); // bad
let _ = foo(); // bad
}
fn foo() {}
fn main() {
(); // fine
foo(); // fine
}