shithub: mc

ref: 62ea6ad22c399c646e396efe264c8314f14027a3
dir: /lib/std/writeall.myr/

View raw version
use "errno.use"
use "result.use"
use "option.use"
use "syswrap.use"
use "types.use"

pkg std =
	const writeall : (fd : fd, src : byte[:] -> (size, option(errno)))
;;

const writeall = {fd, src
	var sz

	sz = src.len
	while src.len != 0
		match std.write(fd, src)
		| `Ok n:
			src = src[n:]
		| `Fail e:
			-> (sz - src.len, `Some e)
		;;
	;;
	-> (sz, `None)
}