diff --git a/stdlib/hashtbl.mli b/stdlib/hashtbl.mli index f67b6711d..f804d2a38 100644 --- a/stdlib/hashtbl.mli +++ b/stdlib/hashtbl.mli @@ -195,10 +195,26 @@ val randomize : unit -> unit @since 4.00.0 *) val is_randomized : unit -> bool -(** return if the tables are currently created in randomized mode by default - +(** Return [true] if the tables are currently created in randomized mode + by default, [false] otherwise. @since 4.03.0 *) +val rebuild : ?random (* thwart tools/unlabel *) :bool -> ('a, 'b) t -> ('a, 'b) t +(** Return a copy of the given hashtable. Unlike {!copy}, + [{!rebuild} h] re-hashes all the (key, value) entries of + the original table [h]. The returned hash table is randomized if + [h] was randomized, or the optional [random] parameter is true, or + if the default is to create randomized hash tables; see + {!create} for more information. + + {!rebuild} can safely be used to import a hash table built + by an old version of the {!Hashtbl} module, then marshaled to + persistent storage. After unmarshaling, apply {!rebuild} + to produce a hash table for the current version of the {!Hashtbl} + module. + + @since 4.12.0 *) + (** @since 4.00.0 *) type statistics = { num_bindings: int; diff --git a/stdlib/moreLabels.mli b/stdlib/moreLabels.mli index fd4b088e8..849409222 100644 --- a/stdlib/moreLabels.mli +++ b/stdlib/moreLabels.mli @@ -206,10 +206,26 @@ val randomize : unit -> unit @since 4.00.0 *) val is_randomized : unit -> bool -(** return if the tables are currently created in randomized mode by default - +(** Return [true] if the tables are currently created in randomized mode + by default, [false] otherwise. @since 4.03.0 *) +val rebuild : ?random (* thwart tools/unlabel *) :bool -> ('a, 'b) t -> ('a, 'b) t +(** Return a copy of the given hashtable. Unlike {!copy}, + [{!rebuild} h] re-hashes all the (key, value) entries of + the original table [h]. The returned hash table is randomized if + [h] was randomized, or the optional [random] parameter is true, or + if the default is to create randomized hash tables; see + {!create} for more information. + + {!rebuild} can safely be used to import a hash table built + by an old version of the {!Hashtbl} module, then marshaled to + persistent storage. After unmarshaling, apply {!rebuild} + to produce a hash table for the current version of the {!Hashtbl} + module. + + @since 4.12.0 *) + (** @since 4.00.0 *) type statistics = Hashtbl.statistics = { num_bindings: int; diff --git a/stdlib/templates/hashtbl.template.mli b/stdlib/templates/hashtbl.template.mli index d2d0f424e..474a0d023 100644 --- a/stdlib/templates/hashtbl.template.mli +++ b/stdlib/templates/hashtbl.template.mli @@ -195,10 +195,26 @@ val randomize : unit -> unit @since 4.00.0 *) val is_randomized : unit -> bool -(** return if the tables are currently created in randomized mode by default - +(** Return [true] if the tables are currently created in randomized mode + by default, [false] otherwise. @since 4.03.0 *) +val rebuild : ?random (* thwart tools/unlabel *) :bool -> ('a, 'b) t -> ('a, 'b) t +(** Return a copy of the given hashtable. Unlike {!copy}, + [{!rebuild} h] re-hashes all the (key, value) entries of + the original table [h]. The returned hash table is randomized if + [h] was randomized, or the optional [random] parameter is true, or + if the default is to create randomized hash tables; see + {!create} for more information. + + {!rebuild} can safely be used to import a hash table built + by an old version of the {!Hashtbl} module, then marshaled to + persistent storage. After unmarshaling, apply {!rebuild} + to produce a hash table for the current version of the {!Hashtbl} + module. + + @since 4.12.0 *) + (** @since 4.00.0 *) type statistics = { num_bindings: int;