| author | |
| committer | |
| log | 3f0f0b7f34922ccc63d2a8e12b4b9d2c8754218c |
| tree | abfd9246490b362f874b4bf2f5d61df3a7b9e5ce |
| parent | 5be076d136ee82ec02fe12278ae182cba8482b72 |
| signature |
2 files changed, 17 insertions(+), 0 deletions(-)
src/Pointee.zig created+16| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | const std = @import("std"); | |
| 2 | const extras = @import("./lib.zig"); | |
| 3 | ||
| 4 | pub fn Pointee(T: type) type { | |
| 5 | return switch (@typeInfo(T)) { | |
| 6 | .pointer => |p| p.child, | |
| 7 | else => T, | |
| 8 | }; | |
| 9 | } | |
| 10 | ||
| 11 | test { | |
| 12 | try std.testing.expect(Pointee(u8) == u8); | |
| 13 | } | |
| 14 | test { | |
| 15 | try std.testing.expect(Pointee(*u8) == u8); | |
| 16 | } |
src/lib.zig+1| ... | ... | @@ -120,3 +120,4 @@ pub usingnamespace @import("./compareFnRange.zig"); |
| 120 | 120 | pub usingnamespace @import("./asciiLower.zig"); |
| 121 | 121 | pub usingnamespace @import("./parseDigits.zig"); |
| 122 | 122 | pub usingnamespace @import("./from_hex.zig"); |
| 123 | pub usingnamespace @import("./Pointee.zig"); |