add Format printers to CCString

This commit is contained in:
Simon Cruanes 2014-10-20 23:29:17 +02:00
parent 1374a2741c
commit ad705fd758
2 changed files with 8 additions and 0 deletions

View file

@ -46,6 +46,7 @@ module type S = sig
val to_list : t -> char list val to_list : t -> char list
val pp : Buffer.t -> t -> unit val pp : Buffer.t -> t -> unit
val print : Format.formatter -> t -> unit
end end
let equal (a:string) b = a=b let equal (a:string) b = a=b
@ -251,6 +252,9 @@ let pp buf s =
Buffer.add_string buf s; Buffer.add_string buf s;
Buffer.add_char buf '"' Buffer.add_char buf '"'
let print fmt s =
Format.fprintf fmt "\"%s\"" s
module Sub = struct module Sub = struct
type t = string * int * int type t = string * int * int
@ -284,4 +288,7 @@ module Sub = struct
Buffer.add_char buf '"'; Buffer.add_char buf '"';
Buffer.add_substring buf s i len; Buffer.add_substring buf s i len;
Buffer.add_char buf '"' Buffer.add_char buf '"'
let print fmt s =
Format.fprintf fmt "\"%s\"" (copy s)
end end

View file

@ -50,6 +50,7 @@ module type S = sig
val to_list : t -> char list val to_list : t -> char list
val pp : Buffer.t -> t -> unit val pp : Buffer.t -> t -> unit
val print : Format.formatter -> t -> unit
end end
(** {2 Strings} *) (** {2 Strings} *)