Assert emptiness on both maps instead of raising custom exception.

https://github.com/c-cube/ocaml-containers/pull/211\#pullrequestreview-107483136
This commit is contained in:
Stavros Polymenis 2018-03-27 23:05:34 +01:00 committed by Simon Cruanes
parent 712b12d2f1
commit 89ce86eec0

View file

@ -45,9 +45,10 @@ module Make(L : OrderedType)(R : OrderedType) = struct
right = MapR.empty;
}
let is_empty m = match MapL.is_empty m.left, MapR.is_empty m.right with
| l, r when l = r -> l
| l, r -> raise (Incoherence ("is_empty left: " ^ string_of_bool l ^ ", right: " ^ string_of_bool r))
let is_empty m =
let res = MapL.is_empty m.left in
assert (res = MapR.is_empty m.right);
res
let add a b m = {
left =