module: correct Objects.is() checker

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2024-12-24 18:05:34 -07:00
parent 94f0648be5
commit eae5aa40be

View file

@ -321,10 +321,13 @@ pub fn Objects(options: ObjectsOptions, comptime T: type) type {
return false; return false;
} }
/// Tells if the given object (which must be alive and valid) is from this pool of objects. /// Tells if the given object is from this pool of objects. If it is, then it must also be
/// alive/valid or else a panic will occur.
pub fn is(objs: *const @This(), id: ObjectID) bool { pub fn is(objs: *const @This(), id: ObjectID) bool {
const unpacked = objs.validateAndUnpack(id, "is"); const unpacked: PackedID = @bitCast(id);
return unpacked.type_id == objs.internal.type_id; if (unpacked.type_id != objs.internal.type_id) return false;
_ = objs.validateAndUnpack(id, "is");
return true;
} }
/// Get the parent of the child, or null. /// Get the parent of the child, or null.