Avoiding duplication of code for readonly or mutable access
Ziggit
Avoiding duplication of code for readonly or mutable access
I am having some trouble creating functions returning const or mutable stuff without duplicating code. This affects the way to write iterators as well. Let’s take a simplified image example. Sometimes I want readonly access, sometimesj mutable access. How to handle this? And while writing this thread I was wondering about the 3d function. Is that legal, the image being const and returning a mutable slice? pub const Image = struct { width: u32, height: u32, pixels: []Pixel, ...
0 comments
No comments yet.