add a bit clarification to HashDB's remove() interface

This commit is contained in:
Guanqun Lu 2017-05-27 11:32:49 +08:00
parent 3111421866
commit 4efd673c19

View File

@ -86,7 +86,7 @@ pub trait HashDB: AsHashDB + Send + Sync {
fn emplace(&mut self, key: H256, value: DBValue);
/// Remove a datum previously inserted. Insertions can be "owed" such that the same number of `insert()`s may
/// happen without the data being eventually being inserted into the DB.
/// happen without the data being eventually being inserted into the DB. It can be "owed" more than once.
///
/// # Examples
/// ```rust
@ -100,6 +100,10 @@ pub trait HashDB: AsHashDB + Send + Sync {
/// let key = &d.sha3();
/// m.remove(key); // OK - we now owe an insertion.
/// assert!(!m.contains(key));
/// m.remove(key); // OK - we now owe two insertions.
/// assert!(!m.contains(key));
/// m.insert(d); // OK - still owed.
/// assert!(!m.contains(key));
/// m.insert(d); // OK - now it's "empty" again.
/// assert!(!m.contains(key));
/// m.insert(d); // OK - now we've