ref: 6c574d4fc09d60095b4d74e865a67a8b1d2b2270
dir: /lib/bio/iter.myr/
use std
use "bio"
pkg bio =
type lineiter = file#
type chariter = file#
impl iterable lineiter -> byte[:]
impl iterable chariter -> char
const byline : (f : file# -> lineiter)
const bychar : (f : file# -> chariter)
;;
const byline = {f
-> (f : lineiter)
}
impl iterable lineiter -> byte[:] =
__iternext__ = {itp, outp
match bio.readln((itp# : file#))
| `Ok ln: outp# = ln
| `Err _: -> false
| `Eof: -> false
;;
-> true
}
__iterfin__ = {itp, outp
std.slfree(outp#)
}
;;
const bychar = {f
-> (f : chariter)
}
impl iterable chariter -> char =
__iternext__ = {itp, outp : char#
match bio.getc((itp# : file#))
| `Ok c: outp# = c
| `Err _: -> false
| `Eof: -> false
;;
-> true
}
__iterfin__ = {itp, outp
}
;;