Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workaround codegen error for Base10.decode #111

Merged
merged 3 commits into from
Aug 24, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions stew/base10.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Copyright (c) 2021 Status Research & Development GmbH
## Copyright (c) 2021-2022 Status Research & Development GmbH
## Licensed under either of
## * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
## * MIT license ([LICENSE-MIT](LICENSE-MIT))
Expand Down Expand Up @@ -39,8 +39,9 @@ type
data*: array[maxLen(Base10, T), byte]
len*: int8 # >= 1 when holding valid unsigned integer

proc decode*[A: byte|char](B: typedesc[Base10], T: typedesc[SomeUnsignedInt],
src: openArray[A]): Result[T, cstring] =
proc decode*[A: byte|char, T: SomeUnsignedInt](
B: typedesc[Base10], t: typedesc[T],
src: openArray[A]): Result[T, cstring] =
## Convert base10 encoded string or array of bytes to unsigned integer.
const
MaxValue = T(high(T) div 10)
Expand Down