≈ the.bay.news

Why is my iterator returning a `const` slice?

Ziggit
Why is my iterator returning a `const` slice?
Hi, I have a buffer full of characters ([]u8). I want to split this buffer in half and modify those halves in place (i.e. without making a copy). My problem is that the iterator only produces []const u8. const std = @import("std"); pub fn main() void { var buffer = [_]u8{ 'a', 'b', 'c', 'd', 'e'}; var pairs = std.mem.splitScalar(u8, &buffer, 'c'); while (pairs.next()) |pair| { // pair[0] = 'X'; // error : cannot assign to constant } } If the iterator input is not c...

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.