Get the latest tech news

Zig's new LinkedList API (it's time to learn fieldParentPtr)


Karl Seguin's Blog - A mix of coding and creative writing

Specifically, unless we're using a packed or extern struct, Zig makes no guarantees about the layout of a structure. To make this code safer, we use the@offsetOf builtin to get the actual byte-offset of a field with respect to its struct: My initial reaction is that I dislike exposing, what I consider, a complicated builtin like@fieldParentPtr for something as trivial as using a linked list.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Time

Time

Photo of zig

zig

Photo of new LinkedList API

new LinkedList API

Related news:

News photo

Original 1977 'Star Wars' Cut Will Be Shown at a Theater for First Time in Decades

News photo

Mapping the half-billion connections that allow mice to see

News photo

For the First Time Astronomers Watch a Black Hole 'Wake Up' in Real-Time