mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
simpler Univ.unpack implementation
This commit is contained in:
parent
93eb787082
commit
73073bdd0c
1 changed files with 4 additions and 6 deletions
4
univ.ml
4
univ.ml
|
|
@ -49,12 +49,10 @@ let embed () =
|
||||||
{ id = id; store = (fun () -> r := o); }
|
{ id = id; store = (fun () -> r := o); }
|
||||||
in
|
in
|
||||||
let unpack t = (* try to extract the content of a univ cell *)
|
let unpack t = (* try to extract the content of a univ cell *)
|
||||||
if id == t.id then begin
|
r := None;
|
||||||
t.store ();
|
t.store ();
|
||||||
let a = !r in
|
let a = !r in
|
||||||
r := None;
|
|
||||||
a
|
a
|
||||||
end else None
|
|
||||||
in
|
in
|
||||||
let set t a = (* change, in place, the embedding and content of the cell *)
|
let set t a = (* change, in place, the embedding and content of the cell *)
|
||||||
t.id <- id;
|
t.id <- id;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue