ref: e1b01e82cbe4968d6cf3c89b543ed2e691bf005f
parent: 220525edb769047fcba3faed66b041c97a752b70
author: Ori Bernstein <ori@eigenstate.org>
date: Sun Dec 28 17:05:58 EST 2014
Add boolean 'strhas()' function.
--- a/libstd/strfind.myr
+++ b/libstd/strfind.myr
@@ -4,6 +4,7 @@
pkg std =
const strfind : (haystack : byte[:], needle : byte[:] -> option(size))
const strrfind : (haystack : byte[:], needle : byte[:] -> option(size))
+ const strhas : (haystack : byte[:], needle : byte[:] -> bool)
;;
const strfind = {haystack, needle
@@ -42,3 +43,9 @@
-> `None
}
+const strhas = {haystack, needle
+ match strfind(haystack, needle)
+ | `Some _: -> true
+ | `None: -> false
+ ;;
+}
\ No newline at end of file