Add zeroed
function to create a zeroed value of any type
#1017
Labels
enhancement
New feature or request
zeroed
function to create a zeroed value of any type
#1017
Problem
As explained in Issue #988, adding a
std::zeroed
function in Noir to return a zeroed value of any type would be useful to create "uninitialized" values for constructs like enums which guarantee these values will note be used.Another possible usecase for such a function is adding a
BoundedVec
type to Noir which is backed by an array internally and has the array's size as its capacity. The array would initially be filled with N instances ofzeroed::<T>()
for some T, and these would be gradually replaced by the actual elements of the vector each time it is pushed to.Proposed solution
We should add
std::zeroed
to our stdlib. Perhaps with a Note explaining why users should be cautious using it (using it on an arbitrary struct could create a struct with invalid invariants if it is used).Alternatives considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: