aboutsummaryrefslogtreecommitdiff
path: root/lib/std/meta
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2023-03-05 12:39:32 +0000
committerAndrew Kelley <andrew@ziglang.org>2023-04-12 12:06:19 -0400
commitccf670c2b04ebeb9db43eb9f5c47c6cf03e4b1d0 (patch)
tree3f7899bf6231500782af185ffe701ee66793e226 /lib/std/meta
parent602029bb2fb78048e46136784e717b57b8de8f2c (diff)
downloadzig-ccf670c2b04ebeb9db43eb9f5c47c6cf03e4b1d0.tar.gz
zig-ccf670c2b04ebeb9db43eb9f5c47c6cf03e4b1d0.zip
Zir: implement explicit block_comptime instruction
Resolves: #7056
Diffstat (limited to 'lib/std/meta')
-rw-r--r--lib/std/meta/trait.zig14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/std/meta/trait.zig b/lib/std/meta/trait.zig
index 843ada7f56..36f0a8924d 100644
--- a/lib/std/meta/trait.zig
+++ b/lib/std/meta/trait.zig
@@ -400,18 +400,18 @@ test "isTuple" {
/// *const u8, ?[]const u8, ?*const [N]u8.
/// ```
pub fn isZigString(comptime T: type) bool {
- comptime {
+ return comptime blk: {
// Only pointer types can be strings, no optionals
const info = @typeInfo(T);
- if (info != .Pointer) return false;
+ if (info != .Pointer) break :blk false;
const ptr = &info.Pointer;
// Check for CV qualifiers that would prevent coerction to []const u8
- if (ptr.is_volatile or ptr.is_allowzero) return false;
+ if (ptr.is_volatile or ptr.is_allowzero) break :blk false;
// If it's already a slice, simple check.
if (ptr.size == .Slice) {
- return ptr.child == u8;
+ break :blk ptr.child == u8;
}
// Otherwise check if it's an array type that coerces to slice.
@@ -419,12 +419,12 @@ pub fn isZigString(comptime T: type) bool {
const child = @typeInfo(ptr.child);
if (child == .Array) {
const arr = &child.Array;
- return arr.child == u8;
+ break :blk arr.child == u8;
}
}
- return false;
- }
+ break :blk false;
+ };
}
test "isZigString" {