Add Maybe<Own<T>>::emplace() to avoid assign-then-assert-nonnull.
I have this pattern: Maybe<Own<T>> foo; // ... foo = heap<T>(); KJ_ASSERT_NONNULL(foo)->doSomething(); The assertion feels non-type-safe. Now you can do: auto& ref = foo.emplace(heap<T>()); ref.doSomething();
Showing
Please
register
or
sign in
to comment