Hacker News new | ask | show | jobs
by benibela 2249 days ago
You can remove the first k elements of a view with data += k.

With the length you would need to do data += k; length -= k

Especially if you want to use it as safe iterator, you can do data++ in a loop

2 comments

> ...You can remove the first k elements of a view with data += k.

How would you safely free(data) afterwards? You'd need to keep an alloc'ed pointer somehow.

Got it. That is really neat, going to add to my bag of tricks...