Explicit synchronous lifetimes with removable, idempotent cleanup for MoonBit
let life = @lifetime.Lifetime()
let release = life.own(fn() { /* close a resource */ })
let child = life.child()
ignore(child.own(fn() { /* remove a subscription */ }))
release.close() // releases early, removing its parent registration
life.close() // also closes the child; repeat calls do nothingpub struct Lifetime {
// private fields
}Install
Download zipExplicit synchronous lifetimes with removable, idempotent cleanup for MoonBit