shithub: mc

ref: 4db5274a2f6db10e31e11c503f36c85a98c65fbc
dir: /lib/std/chomp.myr/

View raw version
use "hasprefix"

pkg std =
	const chomp	: (str : byte[:]#, pfx : byte[:] -> bool)
;;

const chomp = {str, pfx
	if std.hasprefix(str#, pfx)
		str# = str#[pfx.len:]
		-> true
	else
		-> false
	;;
}