#array literal requires address-of operator (&) to coerce to slice type '[]u8'
1 messages · Page 1 of 1 (latest)
it's like the error says: you have an array literal, to make it a slice you have to prefix it with &
if the field is of type []u8, that still won't work; did you meant to use []const u8?
tried with const too
This error has confused quite a few people over the past couple of years, and should probably read more like:
error: array literal cannot coerce into slice type
note: use '&[_]u8{}' or '&.{}' if you mean to make a slice.
using const and & should work
and yeah that error message is a much clearer explanation
It will also work with a mutable slice type, if the array literal has no elements.