Skip to content

Commit 546152b

Browse files
mattcollierbadboy
authored andcommitted
Does not compile due to lifetime.
1 parent 0dcc971 commit 546152b

File tree

1 file changed

+25
-27
lines changed

1 file changed

+25
-27
lines changed

examples/async-multiplexed.rs

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,32 @@ extern crate redis;
33
use futures::{future, prelude::*};
44
use redis::{aio::MultiplexedConnection, RedisResult};
55

6-
fn test_cmd(con: &MultiplexedConnection, i: i32) -> impl Future<Output = RedisResult<()>> + Send {
6+
async fn test_cmd(con: &MultiplexedConnection, i: i32) -> RedisResult<()> {
77
let mut con = con.clone();
8-
async move {
9-
let key = format!("key{}", i);
10-
let key_2 = key.clone();
11-
let key2 = format!("key{}_2", i);
12-
let key2_2 = key2.clone();
13-
14-
let foo_val = format!("foo{}", i);
15-
16-
let () = redis::cmd("SET")
17-
.arg(&key[..])
18-
.arg(foo_val.as_bytes())
19-
.query_async(&mut con)
20-
.await?;
21-
let () = redis::cmd("SET")
22-
.arg(&[&key2, "bar"])
23-
.query_async(&mut con)
24-
.await?;
25-
redis::cmd("MGET")
26-
.arg(&[&key_2, &key2_2])
27-
.query_async(&mut con)
28-
.map(|result| {
29-
assert_eq!(Ok((foo_val, b"bar".to_vec())), result);
30-
Ok(())
31-
})
32-
.await
33-
}
8+
let key = format!("key{}", i);
9+
let key_2 = key.clone();
10+
let key2 = format!("key{}_2", i);
11+
let key2_2 = key2.clone();
12+
13+
let foo_val = format!("foo{}", i);
14+
15+
let () = redis::cmd("SET")
16+
.arg(&key[..])
17+
.arg(foo_val.as_bytes())
18+
.query_async(&mut con)
19+
.await?;
20+
let () = redis::cmd("SET")
21+
.arg(&[&key2, "bar"])
22+
.query_async(&mut con)
23+
.await?;
24+
redis::cmd("MGET")
25+
.arg(&[&key_2, &key2_2])
26+
.query_async(&mut con)
27+
.map(|result| {
28+
assert_eq!(Ok((foo_val, b"bar".to_vec())), result);
29+
Ok(())
30+
})
31+
.await
3432
}
3533

3634
#[tokio::main]

0 commit comments

Comments
 (0)