summaryrefslogtreecommitdiff
path: root/lib/common/format.ml
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2026-04-30 09:16:03 +0200
committerSébastien Dailly <sebastien@dailly.me>2026-05-06 16:45:25 +0200
commit960d5b8f2728f71dd9ce038d527844d82ca2f0f2 (patch)
tree9a15dc43f91a0b58a3aaa10223bba35abf7ef5f2 /lib/common/format.ml
parenta5efd7d15b4d049a4ed539ed5d9c2f1037d00973 (diff)
Allow updates for existing contents
Diffstat (limited to 'lib/common/format.ml')
-rw-r--r--lib/common/format.ml10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/common/format.ml b/lib/common/format.ml
new file mode 100644
index 0000000..5245dd0
--- /dev/null
+++ b/lib/common/format.ml
@@ -0,0 +1,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