| ... | @@ -2511,7 +2511,7 @@ test "null terminated array" { | ... | @@ -2511,7 +2511,7 @@ test "null terminated array" { |
| 2511 | and vectors. Zig provides the {#link|@splat#} builtin to easily convert from scalars | 2511 | and vectors. Zig provides the {#link|@splat#} builtin to easily convert from scalars |
| 2512 | to vectors, and it supports {#link|@reduce#} and array indexing syntax to convert | 2512 | to vectors, and it supports {#link|@reduce#} and array indexing syntax to convert |
| 2513 | from vectors to scalars. Vectors also support assignment to and from fixed-length | 2513 | from vectors to scalars. Vectors also support assignment to and from fixed-length |
| 2514 | arrays with comptime known length. | 2514 | arrays with comptime-known length. |
| 2515 | </p> | 2515 | </p> |
| 2516 | <p> | 2516 | <p> |
| 2517 | For rearranging elements within and between vectors, Zig provides the {#link|@shuffle#} and {#link|@select#} functions. | 2517 | For rearranging elements within and between vectors, Zig provides the {#link|@shuffle#} and {#link|@select#} functions. |
| ... | @@ -2557,7 +2557,7 @@ test "Conversion between vectors, arrays, and slices" { | ... | @@ -2557,7 +2557,7 @@ test "Conversion between vectors, arrays, and slices" { |
| 2557 | var offset: u32 = 1; | 2557 | var offset: u32 = 1; |
| 2558 | // To extract a comptime-known length from a runtime-known offset, | 2558 | // To extract a comptime-known length from a runtime-known offset, |
| 2559 | // first extract a new slice from the starting offset, then an array of | 2559 | // first extract a new slice from the starting offset, then an array of |
| 2560 | // comptime known length | 2560 | // comptime-known length |
| 2561 | const vec3: @Vector(2, f32) = slice[offset..][0..2].*; | 2561 | const vec3: @Vector(2, f32) = slice[offset..][0..2].*; |
| 2562 | try expectEqual(slice[offset], vec2[0]); | 2562 | try expectEqual(slice[offset], vec2[0]); |
| 2563 | try expectEqual(slice[offset + 1], vec2[1]); | 2563 | try expectEqual(slice[offset + 1], vec2[1]); |
| ... | @@ -3013,7 +3013,7 @@ test "slice pointer" { | ... | @@ -3013,7 +3013,7 @@ test "slice pointer" { |
| 3013 | | 3013 | |
| 3014 | {#header_open|Sentinel-Terminated Slices#} | 3014 | {#header_open|Sentinel-Terminated Slices#} |
| 3015 | <p> | 3015 | <p> |
| 3016 | The syntax {#syntax#}[:x]T{#endsyntax#} is a slice which has a runtime known length | 3016 | The syntax {#syntax#}[:x]T{#endsyntax#} is a slice which has a runtime-known length |
| 3017 | and also guarantees a sentinel value at the element indexed by the length. The type does not | 3017 | and also guarantees a sentinel value at the element indexed by the length. The type does not |
| 3018 | guarantee that there are no sentinel elements before that. Sentinel-terminated slices allow element | 3018 | guarantee that there are no sentinel elements before that. Sentinel-terminated slices allow element |
| 3019 | access to the {#syntax#}len{#endsyntax#} index. | 3019 | access to the {#syntax#}len{#endsyntax#} index. |
| ... | @@ -3233,7 +3233,7 @@ test "default struct initialization fields" { | ... | @@ -3233,7 +3233,7 @@ test "default struct initialization fields" { |
| 3233 | .b = 5, | 3233 | .b = 5, |
| 3234 | }; | 3234 | }; |
| 3235 | if (x.a + x.b != 1239) { | 3235 | if (x.a + x.b != 1239) { |
| 3236 | @compileError("it's even comptime known!"); | 3236 | @compileError("it's even comptime-known!"); |
| 3237 | } | 3237 | } |
| 3238 | } | 3238 | } |
| 3239 | {#code_end#} | 3239 | {#code_end#} |
| ... | @@ -4257,7 +4257,7 @@ fn isFieldOptional(comptime T: type, field_index: usize) !bool { | ... | @@ -4257,7 +4257,7 @@ fn isFieldOptional(comptime T: type, field_index: usize) !bool { |
| 4257 | const fields = @typeInfo(T).Struct.fields; | 4257 | const fields = @typeInfo(T).Struct.fields; |
| 4258 | return switch (field_index) { | 4258 | return switch (field_index) { |
| 4259 | // This prong is analyzed `fields.len - 1` times with `idx` being an | 4259 | // This prong is analyzed `fields.len - 1` times with `idx` being an |
| 4260 | // unique comptime known value each time. | 4260 | // unique comptime-known value each time. |
| 4261 | inline 0...fields.len - 1 => |idx| @typeInfo(fields[idx].field_type) == .Optional, | 4261 | inline 0...fields.len - 1 => |idx| @typeInfo(fields[idx].field_type) == .Optional, |
| 4262 | else => return error.IndexOutOfBounds, | 4262 | else => return error.IndexOutOfBounds, |
| 4263 | }; | 4263 | }; |
| ... | @@ -4352,8 +4352,8 @@ const U = union(enum) { | ... | @@ -4352,8 +4352,8 @@ const U = union(enum) { |
| 4352 | | 4352 | |
| 4353 | fn getNum(u: U) u32 { | 4353 | fn getNum(u: U) u32 { |
| 4354 | switch (u) { | 4354 | switch (u) { |
| 4355 | // Here `num` is a runtime known value that is either | 4355 | // Here `num` is a runtime-known value that is either |
| 4356 | // `u.a` or `u.b` and `tag` is `u`'s comptime known tag value. | 4356 | // `u.a` or `u.b` and `tag` is `u`'s comptime-known tag value. |
| 4357 | inline else => |num, tag| { | 4357 | inline else => |num, tag| { |
| 4358 | if (tag == .b) { | 4358 | if (tag == .b) { |
| 4359 | return @floatToInt(u32, num); | 4359 | return @floatToInt(u32, num); |
| ... | @@ -6399,7 +6399,7 @@ test "coercion to error unions" { | ... | @@ -6399,7 +6399,7 @@ test "coercion to error unions" { |
| 6399 | const std = @import("std"); | 6399 | const std = @import("std"); |
| 6400 | const expect = std.testing.expect; | 6400 | const expect = std.testing.expect; |
| 6401 | | 6401 | |
| 6402 | test "coercing large integer type to smaller one when value is comptime known to fit" { | 6402 | test "coercing large integer type to smaller one when value is comptime-known to fit" { |
| 6403 | const x: u64 = 255; | 6403 | const x: u64 = 255; |
| 6404 | const y: u8 = x; | 6404 | const y: u8 = x; |
| 6405 | try expect(y == 255); | 6405 | try expect(y == 255); |