shithub: mc

Download patch

ref: 5f6c159bba1fd3db27b47755644ee5d66e9d086f
parent: c5d8302ee22bebeef2372d7ff33ec6a8756f44b9
author: Ori Bernstein <[email protected]>
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