about summary refs log tree commit diff stats
path: root/src/utils/twtstr.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-06-18 15:10:25 +0200
committerbptato <nincsnevem662@gmail.com>2023-06-18 15:10:25 +0200
commit8157678366345f9040fe146f354e743d41156867 (patch)
tree99d4bbf68e279414de869b7232384ce86893e2fa /src/utils/twtstr.nim
parentaecd7e7d69cab7499f07d1ca40541402bbeb286b (diff)
downloadchawan-8157678366345f9040fe146f354e743d41156867.tar.gz
Use utils/opt in toml parser
Diffstat (limited to 'src/utils/twtstr.nim')
-rw-r--r--src/utils/twtstr.nim11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/utils/twtstr.nim b/src/utils/twtstr.nim
index dd51eb2d..a988c976 100644
--- a/src/utils/twtstr.nim
+++ b/src/utils/twtstr.nim
@@ -11,6 +11,7 @@ import punycode
 import bindings/libunicode
 import data/idna
 import data/charwidth
+import utils/opt
 
 when defined(posix):
   import posix
@@ -391,7 +392,7 @@ func parseInt32*(s: string): Option[int32] =
     inc i
   return some(sign * integer)
 
-func parseInt64*(s: string): Option[int64] =
+func parseInt64*(s: string): Opt[int64] =
   var sign: int64 = 1
   var i = 0
   if i < s.len and s[i] == '-':
@@ -400,19 +401,19 @@ func parseInt64*(s: string): Option[int64] =
   elif i < s.len and s[i] == '+':
     inc i
   if i == s.len or s[i] notin AsciiDigit:
-    return none(int64)
+    return err()
   var integer = int64(decValue(s[i]))
   inc i
   while i < s.len and isDigit(s[i]):
     if unlikely(integer != 0 and high(int64) div 10 < integer):
-      return none(int64) # overflow
+      return err() # overflow
     integer *= 10
     let c = int64(decValue(s[i]))
     if unlikely(high(int64) - c < integer):
-      return none(int64) # overflow
+      return err() # overflow
     integer += c
     inc i
-  return some(sign * integer)
+  return ok(sign * integer)
 
 func parseUInt8*(s: string): Option[uint8] =
   var i = 0