diff --git a/src/core/CCVector.ml b/src/core/CCVector.ml index 3bde49e1..92175e39 100644 --- a/src/core/CCVector.ml +++ b/src/core/CCVector.ml @@ -942,6 +942,9 @@ let to_klist v = else `Cons (v.vec.(i), aux (i+1)) in aux 0 +let to_string ?(start="") ?(stop="") ?(sep=", ") item_to_string v = + to_list v |> CCList.to_string ~start ~stop ~sep item_to_string + let pp ?(start="") ?(stop="") ?(sep=", ") pp_item fmt v = Format.pp_print_string fmt start; iteri diff --git a/src/core/CCVector.mli b/src/core/CCVector.mli index 42f4bd4e..de5b0e6c 100644 --- a/src/core/CCVector.mli +++ b/src/core/CCVector.mli @@ -287,5 +287,11 @@ val to_klist : ('a,_) t -> 'a klist val of_gen : ?init:('a, rw) t -> 'a gen -> ('a, rw) t val to_gen : ('a,_) t -> 'a gen +val to_string : + ?start:string -> ?stop:string -> ?sep:string -> + ('a -> string) -> ('a,_) t -> string +(** Print the vector in a string + @since NEXT_RELEASE *) + val pp : ?start:string -> ?stop:string -> ?sep:string -> 'a printer -> ('a,_) t printer