For a possible implementation see https://github.com/hexops/mach-core/pull/41 (which is fine, but includes more code than just this change)