//# publish // example using generics in a few common/interesting/non-trivial ways module 0x42.Option { import 0x1.vector; struct T has copy, drop, store { v: vector } public none(): Self.T { label b0: return T { v: vector.empty() }; } public some(e: E): Self.T { let v: vector; label b0: v = vector.empty(); vector.push_back(&mut v, move(e)); return T { v: move(v) }; } public unwrap_or(x: Self.T, e: E): E { let v: vector; label b0: T { v: v } = move(x); jump_if (vector.is_empty(&v)) b2; label b1: return vector.pop_back(&mut v); label b2: return move(e); } public really_none(): Self.T { label b0: return Self.unwrap_or>(Self.none>(), Self.none()); } }