Skip to content

Commit

Permalink
module: correct Objects.is() checker
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Gutekanst <[email protected]>
  • Loading branch information
emidoots committed Dec 25, 2024
1 parent 94f0648 commit eae5aa4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/module.zig
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,13 @@ pub fn Objects(options: ObjectsOptions, comptime T: type) type {
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 {
const unpacked = objs.validateAndUnpack(id, "is");
return unpacked.type_id == objs.internal.type_id;
const unpacked: PackedID = @bitCast(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.
Expand Down

0 comments on commit eae5aa4

Please sign in to comment.