std: make IntegerBitSet and ArrayBitSet have defined memory layout

This is useful for wrapping C libraries and native interfaces that make use of bit sets
This commit is contained in:
Silver 2021-12-24 05:38:14 +00:00 committed by Andrew Kelley
parent 67c4b16d6e
commit e0a514df41

View File

@ -50,7 +50,7 @@ pub fn StaticBitSet(comptime size: usize) type {
/// This set is good for sets with a small size, but may generate /// This set is good for sets with a small size, but may generate
/// inefficient code for larger sets, especially in debug mode. /// inefficient code for larger sets, especially in debug mode.
pub fn IntegerBitSet(comptime size: u16) type { pub fn IntegerBitSet(comptime size: u16) type {
return struct { return packed struct {
const Self = @This(); const Self = @This();
// TODO: Make this a comptime field once those are fixed // TODO: Make this a comptime field once those are fixed
@ -287,7 +287,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
", which contains padding bits. Please round this up to an unpadded integer size (i.e. " ++ @typeName(FixedMaskType) ++ ")."); ", which contains padding bits. Please round this up to an unpadded integer size (i.e. " ++ @typeName(FixedMaskType) ++ ").");
} }
return struct { return extern struct {
const Self = @This(); const Self = @This();
// TODO: Make this a comptime field once those are fixed // TODO: Make this a comptime field once those are fixed