shithub: mc

ref: cf57ad51e7ae7744b8a723f6d5fe6d67ca7c509c
dir: /lib/bio/iter.myr/

View raw version
use std
use "bio"

pkg bio =
	type lineiter = file#
	impl iterable lineiter -> byte[:]

	const byline	: (f : file# -> lineiter)
;;

const byline = {f
	-> (f : lineiter)
}

impl iterable lineiter -> byte[:] =
	__iternext__ = {itp, outp
		match bio.readln((itp# : file#))
		| `Ok ln:
			outp# = ln
			-> true
		| `Eof:
			-> false
		| `Err _:
			-> false
		;;
	}

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