Update sentinel type for v0.10.0

Fixes

.../076_sentinels.zig:95:30: error: incompatible types:
  'u32' and '?*const anyopaque':
    while (my_seq[i] != my_sentinel) {
This commit is contained in:
Dave Gauer 2022-03-19 19:38:05 -04:00
parent 3f922a3529
commit f34b6aa024
3 changed files with 13 additions and 6 deletions

View file

@ -41,7 +41,7 @@ Verify the installation and build number of `zig` like so:
```bash ```bash
$ zig version $ zig version
0.9.0-dev.2025+xxxxxxxxx 0.10.0-dev.1427+xxxxxxxxx
``` ```
Clone this repository with Git: Clone this repository with Git:
@ -62,7 +62,7 @@ $ zig build
The Zig language is under very active development. In order to be current, The Zig language is under very active development. In order to be current,
Ziglings tracks **development** builds of the Zig compiler rather than Ziglings tracks **development** builds of the Zig compiler rather than
versioned **release** builds. The last stable release was `0.8.1`, but Ziglings versioned **release** builds. The last stable release was `0.8.1`, but Ziglings
needs a dev build with pre-release version "0.9.0" and a build number at least needs a dev build with pre-release version "0.10.0" and a build number at least
as high as that shown in the example version check above. as high as that shown in the example version check above.
It is likely that you'll download a build which is _greater_ than the minimum. It is likely that you'll download a build which is _greater_ than the minimum.
@ -80,7 +80,13 @@ about input:
[no tab characters or Windows CR/LF newlines are allowed](https://github.com/ziglang/zig/issues/544). [no tab characters or Windows CR/LF newlines are allowed](https://github.com/ziglang/zig/issues/544).
### Version Changes ### Version Changes
..
./patches/healed/076_sentinels.zig:95:30: error: incompatible
types: 'u32' and '?*const anyopaque'
while (my_seq[i] != my_sentinel) {
9
* 2022-03-19 0.10.0-dev.1427 - method for getting sentinel of type changed
* 2021-12-20 0.9.0-dev.2025 - `c_void` is now `anyopaque` * 2021-12-20 0.9.0-dev.2025 - `c_void` is now `anyopaque`
* 2021-06-14 0.9.0-dev.137 - std.build.Id `.Custom` is now `.custom` * 2021-06-14 0.9.0-dev.137 - std.build.Id `.Custom` is now `.custom`
* 2021-04-21 0.8.0-dev.1983 - std.fmt.format() `any` format string required * 2021-04-21 0.8.0-dev.1983 - std.fmt.format() `any` format string required

View file

@ -8,7 +8,7 @@ const print = std.debug.print;
// When changing this version, be sure to also update README.md in two places: // When changing this version, be sure to also update README.md in two places:
// 1) Getting Started // 1) Getting Started
// 2) Version Changes // 2) Version Changes
const needed_version = std.SemanticVersion.parse("0.9.0-dev.2025") catch unreachable; const needed_version = std.SemanticVersion.parse("0.10.0-dev.1427") catch unreachable;
const Exercise = struct { const Exercise = struct {
/// main_file must have the format key_name.zig. /// main_file must have the format key_name.zig.

View file

@ -39,6 +39,7 @@
// data being terminated! // data being terminated!
// //
const print = @import("std").debug.print; const print = @import("std").debug.print;
const sentinel = @import("std").meta.sentinel;
pub fn main() void { pub fn main() void {
// Here's a zero-terminated array of u32 values: // Here's a zero-terminated array of u32 values:
@ -71,12 +72,12 @@ pub fn main() void {
// complete, but there are a couple missing bits. Please fix // complete, but there are a couple missing bits. Please fix
// them! // them!
fn printSequence(my_seq: anytype) void { fn printSequence(my_seq: anytype) void {
const my_type = @typeInfo(@TypeOf(my_seq)); const my_typeinfo = @typeInfo(@TypeOf(my_seq));
// The TypeInfo contained in my_type is a union. We use a // The TypeInfo contained in my_type is a union. We use a
// switch to handle printing the Array or Pointer fields, // switch to handle printing the Array or Pointer fields,
// depending on which type of my_seq was passed in: // depending on which type of my_seq was passed in:
switch (my_type) { switch (my_typeinfo) {
.Array => { .Array => {
print("Array:", .{}); print("Array:", .{});
@ -87,7 +88,7 @@ fn printSequence(my_seq: anytype) void {
}, },
.Pointer => { .Pointer => {
// Check this out - it's pretty cool: // Check this out - it's pretty cool:
const my_sentinel = my_type.Pointer.sentinel; const my_sentinel = sentinel(@TypeOf(my_seq));
print("Many-item pointer:", .{}); print("Many-item pointer:", .{});
// Loop through the items in my_seq until we hit the // Loop through the items in my_seq until we hit the