fix examples

Signed-off-by: ekexium <ekexium@gmail.com>
This commit is contained in:
ekexium 2020-12-24 15:33:29 +08:00
parent da63451caf
commit 6e8eef7fcf
2 changed files with 10 additions and 3 deletions

View File

@ -58,7 +58,10 @@ async fn main() {
let value3: Value = b"value3".to_vec();
txn1.put(key1.clone(), value3).await.unwrap();
txn1.commit().await.unwrap();
let txn3 = client.begin().await.expect("Could not begin a transaction");
let mut txn3 = client.begin().await.expect("Could not begin a transaction");
let result = txn3.get(key1.clone()).await.unwrap().unwrap();
txn3.commit()
.await
.expect("Committing read-only transaction should not fail");
println!("{:?}", (key1, result));
}

View File

@ -15,8 +15,12 @@ async fn puts(client: &Client, pairs: impl IntoIterator<Item = impl Into<KvPair>
}
async fn get(client: &Client, key: Key) -> Option<Value> {
let txn = client.begin().await.expect("Could not begin a transaction");
txn.get(key).await.expect("Could not get value")
let mut txn = client.begin().await.expect("Could not begin a transaction");
let res = txn.get(key).await.expect("Could not get value");
txn.commit()
.await
.expect("Committing read-only transaction should not fail");
res
}
async fn scan(client: &Client, range: impl Into<BoundRange>, limit: u32) {