3.48. kink/io/BIN_OUTPUT¶
3.48.1. BIN_OUTPUT.make_pair¶
BIN_OUTPUT.make_pair makes an output which builds bin from bytes, then returns it with fun which yields a bin.
BIN_OUTPUT.make_pair returns a 2-element vec [Output $gen_bin], where the Output is an output which builds a bin, and $gen_bin is a thunk which returns the build bin.
Example:
:BIN_OUTPUT.require_from('kink/io/')
:BIN.require_from('kink/')
:make_bin <- {
[:Out :gen_bin] = BIN_OUTPUT.make_pair
Out.write_bin(BIN.of(1 2 3))
Out.write_byte(4)
Out.close
gen_bin
}
stdout.print_line(make_bin.repr) # => BIN.of(0x01 0x02 0x03 0x04)
.close and .flush method do nothing for the result Output, thus you don't have to call .close for the Output.