summaryrefslogtreecommitdiff
path: root/lib/ur/string.ur
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ur/string.ur')
-rw-r--r--lib/ur/string.ur10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/ur/string.ur b/lib/ur/string.ur
index f19ce174..f7781e01 100644
--- a/lib/ur/string.ur
+++ b/lib/ur/string.ur
@@ -11,7 +11,15 @@ val suffix = Basis.strsuffix
val index = Basis.strindex
val atFirst = Basis.strchr
-fun mindex {Haystack = s, Needle = chs} = Basis.strcspn s chs
+fun mindex {Haystack = s, Needle = chs} =
+ let
+ val n = Basis.strcspn s chs
+ in
+ if n >= length s then
+ None
+ else
+ Some n
+ end
fun substring s {Start = start, Len = len} = Basis.substring s start len