File tree Expand file tree Collapse file tree 4 files changed +19
-0
lines changed
Expand file tree Collapse file tree 4 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -466,6 +466,12 @@ let to_seq a =
466466
467467let to_iter a k = iter k a
468468
469+ let of_iter (i : 'a iter ) : 'a array =
470+ let open CCVector in
471+ let vec = create () in
472+ i (push vec);
473+ to_array vec
474+
469475let to_gen a =
470476 let k = ref 0 in
471477 fun () ->
Original file line number Diff line number Diff line change @@ -240,6 +240,11 @@ val to_iter : 'a t -> 'a iter
240240 in modification of the iterator.
241241 @since 2.8 *)
242242
243+ val of_iter : 'a iter -> 'a t
244+ (* * [of_iter iter] builds a array from a given [iter].
245+ In the result, elements appear in the same order as they did in the source [iter].
246+ @since 3.15 *)
247+
243248val to_seq : 'a t -> 'a Seq .t
244249(* * [to_seq a] returns a [Seq.t] of the elements of an array [a].
245250 The input array [a] is shared with the sequence and modification of it will result
Original file line number Diff line number Diff line change @@ -248,6 +248,11 @@ val to_iter : 'a t -> 'a iter
248248 in modification of the iterator.
249249 @since 2.8 *)
250250
251+ val of_iter : 'a iter -> 'a t
252+ (* * [of_iter iter] builds a array from a given [iter].
253+ In the result, elements appear in the same order as they did in the source [iter].
254+ @since 3.15 *)
255+
251256val to_seq : 'a t -> 'a Seq .t
252257(* * [to_seq a] returns a [Seq.t] of the elements of an array [a].
253258 The input array [a] is shared with the sequence and modification of it will result
Original file line number Diff line number Diff line change @@ -309,3 +309,6 @@ q ~count:300 arr_arbitrary (fun a ->
309309 Array. sort CCInt. compare a1;
310310 sort_generic (module IA ) ~cmp: CCInt. compare a2;
311311 a1 = a2)
312+ ;;
313+
314+ q Q. (array int ) (fun a -> of_iter (to_iter a) = a)
You can’t perform that action at this time.
0 commit comments