summaryrefslogtreecommitdiffstats
path: root/stdlib
diff options
context:
space:
mode:
authorWojciech Meyer <wojciech.meyer@gmail.com>2011-12-29 03:10:49 +0000
committerWojciech Meyer <wojciech.meyer@gmail.com>2011-12-29 03:10:49 +0000
commitc1eebeea6050bb4e6c4af31b3a7220bff8809de8 (patch)
treedd15e61dacff129692678d788c7c4dc7f0b7d1ca /stdlib
parent33eefe487458744155acff18292a3d24b4229282 (diff)
Fix PR#5454: Add compare to Digest and allow to pass directly Digest to Set.Make and Map.Make
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@11971 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/digest.ml3
-rw-r--r--stdlib/digest.mli7
2 files changed, 9 insertions, 1 deletions
diff --git a/stdlib/digest.ml b/stdlib/digest.ml
index 7d6914156..47c7e65a7 100644
--- a/stdlib/digest.ml
+++ b/stdlib/digest.ml
@@ -17,6 +17,8 @@
type t = string
+let compare = String.compare
+
external unsafe_string: string -> int -> int -> t = "caml_md5_string"
external channel: in_channel -> int -> t = "caml_md5_chan"
@@ -48,4 +50,3 @@ let to_hex d =
String.blit (Printf.sprintf "%02x" (int_of_char d.[i])) 0 result (2*i) 2;
done;
result
-;;
diff --git a/stdlib/digest.mli b/stdlib/digest.mli
index 14f27e263..ac41153d9 100644
--- a/stdlib/digest.mli
+++ b/stdlib/digest.mli
@@ -24,6 +24,13 @@
type t = string
(** The type of digests: 16-character strings. *)
+val compare : t -> t -> int
+(** The comparison function for 16-character digest, with the same
+ specification as {!Pervasives.compare} and the implementation
+ shared with {!String.compare}. Along with the type [t], this
+ function [compare] allows the module [Digest] to be passed as
+ argument to the functors {!Set.Make} and {!Map.Make}. *)
+
val string : string -> t
(** Return the digest of the given string. *)