package batteries

  1. Overview
  2. Docs
A community-maintained standard library extension

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v3.7.2.tar.gz
md5=1fd7bddce07cf5d244fc9427f7b5e4d4
sha512=c0f2a0fdc8253e0ea999d8d4c58bfbf32b18d251a2e1d9656bf279de5f01a33e9aabac3af4d95f465f8b671e7711ebd37218043face233340a0c11b08fa62f78

doc/src/batteries.unthreaded/batBytesCompat.ml.html

Source file batBytesCompat.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
(* This compatible module contains compatibility versions of stdlib
   functions that are commonly used when porting code to the
   (string / bytes) separation, but are not available in older OCaml
   versions that Batteries support.

   We could push each function in the corresponding Batteries module
   (Buffer.add_subbtypes into BatBuffer, etc.), but this would have
   the effect of turning dependencies on the stdlib into
   inter-Batteries-module dependencies: any module using
   Buffer.add_subbtypes would then depend on the whole BatBuffer,
   increasing binary sizes and risk of cycles.
*)

##V>=4.2##let string_init = String.init
##V<4.2##let string_init len f =
##V<4.2##  let s = Bytes.create len in
##V<4.2##  for i = 0 to len - 1 do
##V<4.2##    Bytes.unsafe_set s i (f i)
##V<4.2##  done;
##V<4.2##  Bytes.unsafe_to_string s

##V>=4.2##let buffer_add_subbytes = Buffer.add_subbytes
##V<4.2##let buffer_add_subbytes = Buffer.add_substring

##V>=4.2##let buffer_to_bytes = Buffer.to_bytes
##V<4.2##let buffer_to_bytes = Buffer.contents
OCaml

Innovation. Community. Security.