#packed enum to u8 bytes?
1 messages · Page 1 of 1 (latest)
is out an arraylist of u8s?
in that case why not just do try out.append(@truncate(@bitCast(self.parsing)))?
the & 0xFF is probably screwing up the result type and @truncate will already mask it for you
Wow, well this is unexpected:
OMG, so this doesnt work either:
Nor does this:
Maybe an inline function is needed to mash out a u32 into u8's for an array.... hmmm...
omg, this doesnt work either
var b: u8 = @as(u8, @bitCast(self.uid));
src/form.zig:66:25: error: @bitCast size mismatch: destination type 'u8' has 8 bits but source type 'u32' has 32 bits
var b: u8 = @as(u8, @bitCast(self.uid));
Nor does this:
Maybe @bitcast is not the answer for getting a u32 into u8's
I guess you'd do @truncate(@as(u32, @bitCast(self.parsing)))
Which makes sense ig truncate doesn't provide a result type
Thans, I finally worked it out after a lot of trial and error, heres how: