Skip to content

Commit

Permalink
[kvdb-memorydb] Migrated code to 2018 edition, updated parking_lot (#222
Browse files Browse the repository at this point in the history
)

* Migrated code to 2018 edition, updated parking_lot

* revert parking_lot update due to breakages
  • Loading branch information
Ashley authored and dvdplm committed Sep 23, 2019
1 parent baf1df9 commit 085d18b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
3 changes: 2 additions & 1 deletion kvdb-memorydb/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[package]
name = "kvdb-memorydb"
version = "0.1.0"
version = "0.1.1"
authors = ["Parity Technologies <admin@parity.io>"]
repository = "https://github.com/paritytech/parity-common"
description = "A key-value in-memory database that implements the `KeyValueDB` trait"
license = "GPL-3.0"
edition = "2018"

[dependencies]
parking_lot = "0.6"
Expand Down
10 changes: 3 additions & 7 deletions kvdb-memorydb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

extern crate parking_lot;
extern crate kvdb;

use std::collections::{BTreeMap, HashMap};
use std::io;
use std::{io, collections::{BTreeMap, HashMap}};
use parking_lot::RwLock;
use kvdb::{DBValue, DBTransaction, KeyValueDB, DBOp};

Expand Down Expand Up @@ -87,7 +83,7 @@ impl KeyValueDB for InMemory {
Ok(())
}

fn iter<'a>(&'a self, col: Option<u32>) -> Box<Iterator<Item=(Box<[u8]>, Box<[u8]>)> + 'a> {
fn iter<'a>(&'a self, col: Option<u32>) -> Box<dyn Iterator<Item=(Box<[u8]>, Box<[u8]>)> + 'a> {
match self.columns.read().get(&col) {
Some(map) => Box::new( // TODO: worth optimizing at all?
map.clone()
Expand All @@ -99,7 +95,7 @@ impl KeyValueDB for InMemory {
}

fn iter_from_prefix<'a>(&'a self, col: Option<u32>, prefix: &'a [u8])
-> Box<Iterator<Item=(Box<[u8]>, Box<[u8]>)> + 'a>
-> Box<dyn Iterator<Item=(Box<[u8]>, Box<[u8]>)> + 'a>
{
match self.columns.read().get(&col) {
Some(map) => Box::new(
Expand Down

0 comments on commit 085d18b

Please sign in to comment.