aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorLewis Gaul <lewis.gaul@gmail.com>2021-11-21 21:27:51 +0000
committerAndrew Kelley <andrew@ziglang.org>2021-11-22 21:30:20 -0500
commitbc3e86c4b7e595eab9951a847c6637bb8f2a7451 (patch)
tree39f5108635f169b6d6635d26e6ca91ceaf208643 /lib/std
parent11330cbcc55f7d7dbd2de2f5acd7b097cd19788c (diff)
downloadzig-bc3e86c4b7e595eab9951a847c6637bb8f2a7451.tar.gz
zig-bc3e86c4b7e595eab9951a847c6637bb8f2a7451.zip
Add std.meta.Float, alongside std.meta.Int
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/meta.zig13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/std/meta.zig b/lib/std/meta.zig
index 67f12e12c1..db9bd8ca78 100644
--- a/lib/std/meta.zig
+++ b/lib/std/meta.zig
@@ -866,6 +866,19 @@ pub fn Int(comptime signedness: std.builtin.Signedness, comptime bit_count: u16)
});
}
+pub fn Float(comptime bit_count: u8) type {
+ return @Type(TypeInfo{
+ .Float = .{ .bits = bit_count },
+ });
+}
+
+test "std.meta.Float" {
+ try testing.expectEqual(f16, Float(16));
+ try testing.expectEqual(f32, Float(32));
+ try testing.expectEqual(f64, Float(64));
+ try testing.expectEqual(f128, Float(128));
+}
+
pub fn Vector(comptime len: u32, comptime child: type) type {
return @Type(TypeInfo{
.Vector = .{