diff --git a/src/entity.zig b/src/entity.zig index 1e9b0d7..6771744 100644 --- a/src/entity.zig +++ b/src/entity.zig @@ -198,7 +198,7 @@ pub fn Entity(comptime ctx: anytype) type { } pub fn asId(self: Self) Id(ctx) { - return @bitCast(self); + return .{ .world = self.world, .raw = self.raw }; } pub fn getEntityId(self: Self) u32 { diff --git a/src/id.zig b/src/id.zig index 4f07e7c..c5d4190 100644 --- a/src/id.zig +++ b/src/id.zig @@ -57,7 +57,7 @@ pub fn Id(comptime ctx: anytype) type { /// Returns this `Id` as an `Entity`, or `null` otherwise. /// This assumes the `Id` is valid, or an invalid result could be returned. pub fn asEntityUnsafe(self: Self) ?Entity(ctx) { - return if (isEntity(self)) @bitCast(self) else null; + return if (isEntity(self)) .{ .world = self.world, .raw = self.raw } else null; } pub fn isPair(self: Self) bool { @@ -68,19 +68,19 @@ pub fn Id(comptime ctx: anytype) type { /// a pair, or either of its elements are not valid or not alive in /// the world. pub fn asPairAlive(self: Self) !Pair(ctx) { - return @as(Pair(ctx), @bitCast(self)).ensureAlive(); + return @as(Pair(ctx), .{ .world = self.world, .raw = self.raw }).ensureAlive(); } /// Attempts to return this `Id` as a `Pair`, or an error if it's not /// a pair, or either of its elements are not valid. pub fn asPairValid(self: Self) !Pair(ctx) { - return @as(Pair(ctx), @bitCast(self)).ensureValid(); + return @as(Pair(ctx), .{ .world = self.world, .raw = self.raw }).ensureValid(); } /// Returns this `Id` as a `Pair`, or `null` otherwise. /// This assumes the `Id` is valid, or an invalid result could be returned. pub fn asPairUnsafe(self: Self) ?Pair(ctx) { - return if (isPair(self)) @bitCast(self) else null; + return if (isPair(self)) .{ .world = self.world, .raw = self.raw } else null; } pub fn isWildcard(self: Self) bool { diff --git a/src/pair.zig b/src/pair.zig index 727de5e..e590014 100644 --- a/src/pair.zig +++ b/src/pair.zig @@ -57,7 +57,7 @@ pub fn Pair(comptime ctx: anytype) type { } pub fn asId(self: Self) Id(ctx) { - return @bitCast(self); + return .{ .world = self.world, .raw = self.raw }; } pub fn getRelation(self: Self) Entity(ctx) {