shithub: mc

ref: 034acf0ceac80411fc85bbd4cc9e237d26a6e36c
dir: /lib/std/writeall.myr/

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

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:]
		| `Err e:
			-> (sz - src.len, `Some e)
		;;
	;;
	-> (sz, `None)
}