module: correct Objects.is() checker
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
94f0648be5
commit
eae5aa40be
1 changed files with 6 additions and 3 deletions
|
|
@ -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.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue