summaryrefslogtreecommitdiff
path: root/lib/common/format.ml
blob: 5245dd0f5ec88f2cc956e058e730653490a586fb (plain)
1
2
3
4
5
6
7
8
9
10
(** [format_string f] call the function [f] with a fresh formatter and return
    the content as a string *)
let format_string : (Stdlib.Format.formatter -> unit) -> string =
 fun f ->
  let buff = Buffer.create 16 in
  let format = Stdlib.Format.formatter_of_buffer buff in
  let () = f format in

  Stdlib.Format.pp_print_flush format ();
  Buffer.contents buff