shithub: mc

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

View raw version
use "alloc"
use "dir"
use "option"

pkg std =
	type diriter = dir#
	impl iterable diriter -> byte[:]

	const byentry	: (d : dir# -> diriter)
;;

const byentry = {d
	-> d castto(diriter)
}

impl iterable diriter -> byte[:] =
	__iternext__ = {itp, valp
		match dirread(itp# castto(dir#))
		| `Some ent:
			valp# = ent
			-> true
		| `None:
			-> false
		;;
	}

	__iterfin__ = {itp, valp
		std.slfree(valp#)
	}
;;