-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove deprecated support for Option
- Loading branch information
1 parent
72a8872
commit 3b53f41
Showing
3 changed files
with
13 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
import | ||
std/options, | ||
../rlp | ||
import ../rlp | ||
|
||
proc read*[T](rlp: var Rlp, O: type Option[T]): O {.inline.} = | ||
mixin read | ||
if not rlp.isEmpty: | ||
result = some read(rlp, T) | ||
proc append*[T](w: var RlpWriter, val: Opt[T]) = | ||
mixin append | ||
|
||
if val.isSome: | ||
w.append(val.get()) | ||
else: | ||
w.append("") | ||
|
||
proc append*(writer: var RlpWriter, value: Option) = | ||
if value.isSome: | ||
writer.append value.get | ||
proc read*[T](rlp: var Rlp, val: var Opt[T]) {.raises: [RlpError].} = | ||
mixin read | ||
if rlp.blobLen != 0: | ||
val = Opt.some(rlp.read(T)) | ||
else: | ||
writer.append "" | ||
rlp.skipElem | ||
|
||
export | ||
options, rlp |