ratfactor / ziglings

Learn the Zig programming language by fixing tiny broken programs.
MIT License
4.29k stars 485 forks source link

078_sentinels 3 uses wrong signature #334

Closed dev-cyprium closed 1 year ago

dev-cyprium commented 1 year ago

In the task the issue is explained:

//
// We were able to get a printable string out of a many-item
// pointer by using a slice to assert a specific length.
//
// But can we ever GO BACK to a sentinel-terminated pointer
// after we've "lost" the sentinel in a coercion?
//
// Yes, we can. Zig's @ptrCast() builtin can do this. Check out
// the signature:
//
//     @ptrCast(comptime DestType: type, value: anytype) DestType
//
// See if you can use it to solve the same many-item pointer
// problem, but without needing a length!
//

However, in the latest version of zig I'm using @ptrCast() only takes a value. Is this intended?

chrboesch commented 1 year ago

Is this intended?

Sorry, no. The changes to the cast functions were about 3 days ago and I didn't see everything what we need to adjust. See also: https://github.com/ratfactor/ziglings/issues/332