def construct
bend-collections-laws-crypto@1.0.0.0 · proofs/lib/lemmas/src/cache.bend:22
import bend-collections-laws-crypto@1.0.0.0/proofs/lib/lemmas/src/cache.bend as Cache
import Base
22def construct(-K: Data, -V: Data, capacity: U32, size: U32, zero: Bool, reserved: Bool, small: Bool) -> Result<&2, &2, String, Cache<K, V>>:
23 match zero reserved small:
24 case True{} a b:
25 Fail{"capacity must be positive"}
26 case False{} True{} b:
27 Fail{"size must not be 0XFFFFFFFF"}
28 case False{} False{} True{}:
29 Fail{"size (" ++ U32.show(size) ++ ") is smaller than capacity (" ++ U32.show(capacity) ++ ")"}
30 case False{} False{} False{}:
31 Done{init(K, V, U32.to_nat(capacity))}