implement ptr::to_uint without unsafe