| 1 | const std = @import("std"); |
| 2 | const string = []const u8; |
| 3 | const extras = @import("./lib.zig"); |
| 4 | |
| 5 | /// ?A == A fails |
| 6 | /// ?A == @as(?A, b) works |
| 7 | /// Sourced from https://github.com/ziglang/zig/issues/12609 |
| 8 | pub fn is(a: anytype, b: @TypeOf(a)) bool { |
| 9 | return a == b; |
| 10 | } |
| 11 | |
| 12 | test { |
| 13 | try std.testing.expect(is(@as(u8, 5), 5)); |
| 14 | } |
| 15 | test { |
| 16 | try std.testing.expect(is(@as(?u8, 5), 5)); |
| 17 | } |
| 18 | test { |
| 19 | try std.testing.expect(!is(@as(u8, 5), 8)); |
| 20 | } |
| 21 | test { |
| 22 | try std.testing.expect(!is(@as(?u8, 5), 8)); |
| 23 | } |