OCamlでBytesのデータをBytesへコピーしたい
#OCaml
Bytes.blit を使えば良さそう
https://v2.ocaml.org/api/Bytes.html
code:ocaml
(* 転送先のBytes *)
utop # let b1 = Bytes.make 8 '\x00';;
val b1 : bytes = Bytes.of_string "\000\000\000\000\000\000\000\000"
(* 転送元のBytes *)
utop # let b2 = Bytes.of_string "ABCDEFGH";;
val b2 : bytes = Bytes.of_string "ABCDEFGH"
(* 転送元の0バイト目から転送先の4バイト目へ4バイトのデータを転送 *)
utop # Bytes.blit b2 0 b1 4 4;;
- : unit = ()
(* 結果 *)
utop # b1;;
- : bytes = Bytes.of_string "\000\000\000\000ABCD"