123456789101112131415161718192021222324252627282930313233343536373839open!Core_kernelopen!Importtype'at='aref(* Being a pointer, no one outside this module can construct a value that is
[phys_same] as this one.
this code is duplicated in Option_array.Cheap_option, and if we find yet another
place where we want it we should reconsider making it shared. *)letnone=Obj.obj(Obj.new_blockObj.abstract_tag1)letcreate()=refnoneletis_nonex=phys_equal!xnoneletis_somex=not(is_nonex)letget_some_exnx=ifis_nonexthenraise_s[%message"Moption.get_some_exn"]else!xletgett=ifis_nonetthenNoneelseSome!tletunsafe_gett=!tletset_sometv=t:=vletset_nonet=t:=noneletsettv=matchvwith|None->set_nonet|Somev->set_sometv;;letsexp_of_tsexp_of_at=[%sexp(gett:aoption)]letinvariantinvariant_at=Invariant.invariant[%here]t[%sexp_of:_t](fun()->Option.iter(gett)~f:invariant_a);;moduleOptional_syntax=structmoduleOptional_syntax=structletis_none=is_noneletunsafe_value=unsafe_getendend