shithub: mc

ref: 63405aa8ca5abcca5cf1b1abb4c0b3648aa5bfc4
dir: /lib/std/striter.myr/

View raw version
use "die"
use "types"
use "utf"

pkg std =
	type chariter = struct
		rest	: byte[:]
	;;

	impl iterable chariter -> char

	const bychar	: (str : byte[:] -> chariter)
;;

impl iterable chariter -> char =
	__iternext__ = {ci, c
		if ci.rest.len == 0
			-> false
		;;
		(c#, ci.rest) = strstep(ci.rest)
		-> true
	}

	__iterfin__ = {ci, c
	}
;;

const bychar = {str
	-> [.rest = str]
}