From 3dfbbeb3e3ebf9f7cb33b9a341e65985cd1c4727 Mon Sep 17 00:00:00 2001 From: Fardale Date: Mon, 28 Oct 2019 14:05:48 +0100 Subject: [PATCH] add `CCChar.to_string` --- src/core/CCChar.ml | 6 ++++++ src/core/CCChar.mli | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/core/CCChar.ml b/src/core/CCChar.ml index 4323a764..57556956 100644 --- a/src/core/CCChar.ml +++ b/src/core/CCChar.ml @@ -16,6 +16,12 @@ let of_int_exn = Char.chr let of_int c = try Some (of_int_exn c) with _ -> None let to_int = Char.code +let to_string c = String.make 1 c + +(*$Q to_string + (Q.string_of_size (Q.Gen.return 1)) (fun s -> to_string s.[0] = s) +*) + let lowercase_ascii = function | 'A'..'Z' as c -> Char.unsafe_chr (Char.code c + 32) | c -> c diff --git a/src/core/CCChar.mli b/src/core/CCChar.mli index 974e9096..3e9f3fa3 100644 --- a/src/core/CCChar.mli +++ b/src/core/CCChar.mli @@ -40,6 +40,10 @@ val to_int : t -> int Return the ASCII code of the argument. @since 1.0 *) +val to_string : t -> string +(** [to_string c] return a string containing [c] + @since NEXT_RELEASE *) + val pp_buf : Buffer.t -> t -> unit (** Renamed from [pp] since 2.0. *)