diff --git a/README.md b/README.md index 1eb7f0e..5625461 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,9 @@ fn main() { None => println!("did not read valid utf-8 out of the db"), } - }).on_absent(|| { println!("value not found") }); + }) + .on_absent( || { println!("value not found") }) + .on_error( |e| { println!("error retrieving value: {}", e) }); db.delete(b"my key"); diff --git a/src/main.rs b/src/main.rs index 531e9d3..2c948bd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,18 +7,20 @@ use test::Bencher; fn main() { match rocksdb::create_or_open("/tmp/rust-rocksdb".to_string()) { Ok(db) => { - db.put(b"my key", b"my value"); + assert!(db.put(b"my key", b"my value").is_ok()); db.get(b"my key").map( |value| { match value.to_utf8() { Some(v) => - println!("retrieved utf8 value {}", v), + println!("retrieved utf8 value: {}", v), None => println!("did not read valid utf-8 out of the db"), } - }).on_absent(|| { println!("value not found") }); + }) + .on_absent( || { println!("value not found") }) + .on_error( |e| { println!("error retrieving value: {}", e) }); - db.delete(b"my key"); + assert!(db.delete(b"my key").is_ok()); db.close(); },