From ad705fd75823e5374ba2b89f8cd1298891a69fd3 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Mon, 20 Oct 2014 23:29:17 +0200 Subject: [PATCH] add Format printers to CCString --- core/CCString.ml | 7 +++++++ core/CCString.mli | 1 + 2 files changed, 8 insertions(+) diff --git a/core/CCString.ml b/core/CCString.ml index 6d926f43..f1a6ee14 100644 --- a/core/CCString.ml +++ b/core/CCString.ml @@ -46,6 +46,7 @@ module type S = sig val to_list : t -> char list val pp : Buffer.t -> t -> unit + val print : Format.formatter -> t -> unit end let equal (a:string) b = a=b @@ -251,6 +252,9 @@ let pp buf s = Buffer.add_string buf s; Buffer.add_char buf '"' +let print fmt s = + Format.fprintf fmt "\"%s\"" s + module Sub = struct type t = string * int * int @@ -284,4 +288,7 @@ module Sub = struct Buffer.add_char buf '"'; Buffer.add_substring buf s i len; Buffer.add_char buf '"' + + let print fmt s = + Format.fprintf fmt "\"%s\"" (copy s) end diff --git a/core/CCString.mli b/core/CCString.mli index 78059fff..8945e525 100644 --- a/core/CCString.mli +++ b/core/CCString.mli @@ -50,6 +50,7 @@ module type S = sig val to_list : t -> char list val pp : Buffer.t -> t -> unit + val print : Format.formatter -> t -> unit end (** {2 Strings} *)