support minimum nim version 0.18.0

This commit is contained in:
Xie Yanbo 2020-02-18 23:46:17 +08:00
parent 533d4ed7e8
commit 9bd4ed57cd
3 changed files with 11 additions and 5 deletions

View File

@ -18,6 +18,12 @@ matrix:
include:
- os: linux
env: CHANNEL=stable
- os: linux
env: CHANNEL=0.20.2
- os: linux
env: CHANNEL=0.19.6
- os: linux
env: CHANNEL=0.18.0
install:
- |

View File

@ -12,4 +12,4 @@ bin = @["leveldb"]
# Dependencies
requires "nim >= 1.0.0"
requires "nim >= 0.18.0"

View File

@ -193,7 +193,7 @@ iterator iter*(self: LevelDb, seek: string = "", reverse: bool = false): (
leveldb_iter_next(iterPtr)
iterator iterPrefix*(self: LevelDb, prefix: string): (string, string) =
for (key, value) in iter(self, prefix, reverse = false):
for key, value in iter(self, prefix, reverse = false):
if key.startsWith(prefix):
yield (key, value)
else:
@ -201,7 +201,7 @@ iterator iterPrefix*(self: LevelDb, prefix: string): (string, string) =
iterator iterRange*(self: LevelDb, start, limit: string): (string, string) =
let reverse: bool = limit < start
for (key, value) in iter(self, start, reverse = reverse):
for key, value in iter(self, start, reverse = reverse):
if reverse:
if key < limit:
break
@ -331,7 +331,7 @@ when isMainModule:
db.close()
elif args[0] == "list":
db = open(dbPath)
for (key, value) in db.iter():
for key, value in db.iter():
if hex:
echo key, " ", value.toHex()
else:
@ -339,7 +339,7 @@ when isMainModule:
db.close()
elif args[0] == "keys":
db = open(dbPath)
for (key, value) in db.iter():
for key, value in db.iter():
echo key
db.close()
elif args[0] == "delete":