From 78ef007b772c4443a90b57bbe906dd38b2018c75 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Wed, 20 Nov 2019 17:50:22 -0600 Subject: [PATCH] deprecate `CCOpt.to_seq`, provide `to_iter` instead --- src/core/CCOpt.ml | 4 +++- src/core/CCOpt.mli | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/core/CCOpt.ml b/src/core/CCOpt.ml index 3610d897..d28ff739 100644 --- a/src/core/CCOpt.ml +++ b/src/core/CCOpt.ml @@ -204,10 +204,12 @@ let to_gen o = let first = ref true in fun () -> if !first then (first:=false; o) else None -let to_seq o k = match o with +let to_iter o k = match o with | None -> () | Some x -> k x +let to_seq = to_iter + let pp ppx out = function | None -> Format.pp_print_string out "None" | Some x -> Format.fprintf out "@[Some %a@]" ppx x diff --git a/src/core/CCOpt.mli b/src/core/CCOpt.mli index a634aa9c..6d400b23 100644 --- a/src/core/CCOpt.mli +++ b/src/core/CCOpt.mli @@ -186,6 +186,13 @@ val choice_seq : 'a t sequence -> 'a t @since 0.13 *) val to_gen : 'a t -> 'a gen + +val to_iter : 'a t -> 'a sequence +(** Returns an internal iterator, like in the library [Iter]. + @since NEXT_RELEASE *) + val to_seq : 'a t -> 'a sequence +(** Previous name for {!to_iter} + @deprecated use {!to_iter} instead *) val pp : 'a printer -> 'a t printer