zig icon indicating copy to clipboard operation
zig copied to clipboard

bit_set: Make DynamicBitSetUnmanaged take an int type

Open N00byEdge opened this issue 3 years ago • 11 comments

This allows you to create a DynamicBitSetUnmanaged with a different backing integer type, useful for when being passed for example a [*]u32 or [*]u8 from an external API with no usize alignment gurantees. The null argument uses the old behaviour.

N00byEdge avatar Jul 26 '22 01:07 N00byEdge

I don't think the int type should be an optional. We should instead expose a constant declaration like pub const DynamicBitSetDefaultUnmanaged = DynamicBitSetUnmanaged(usize);. This should also be done for the managed version.

SpexGuy avatar Jul 26 '22 04:07 SpexGuy

@SpexGuy Would you prefer pub const DynamicBitSetUnmanaged = DynamicBitSetCustomUnmanaged(usize);?

N00byEdge avatar Jul 26 '22 09:07 N00byEdge

As I think you may be sleeping at this time, I will just implement that API since I think it's a lot nicer, but feel free to disagree and I can swap the names around

N00byEdge avatar Jul 26 '22 09:07 N00byEdge

I went with Spex' names instead after Luuk chimed in

N00byEdge avatar Jul 26 '22 10:07 N00byEdge

That CI fail looks unrelated, right?

N00byEdge avatar Jul 26 '22 14:07 N00byEdge

I like your names better actually, especially if DynamicBitSet will continue to be a single type and not generic. But I'm not strongly opinionated about it.

SpexGuy avatar Jul 26 '22 14:07 SpexGuy

Yeah, I considered not breaking the API as a decently sized plus as most users won't care about this, but I'm not sure compat for the sake of compat is even worth considering before 1.0.

N00byEdge avatar Jul 26 '22 14:07 N00byEdge

True but it's not just for the sake of compat. Customizing the int type is a rare use case, the default should be usize. So that version should have a shorter name.

SpexGuy avatar Jul 26 '22 14:07 SpexGuy

Should I change it back then?

N00byEdge avatar Jul 26 '22 15:07 N00byEdge

IMO yes but I haven't seen Luuk's opinion/reasoning.

SpexGuy avatar Jul 26 '22 16:07 SpexGuy

I don't want to spend too much time on bikeshedding here, I changed the names back to what I think was better.

N00byEdge avatar Jul 27 '22 19:07 N00byEdge

I apologize for not getting to this earlier, but it now needs a rebase and to run additional CI checks. Please re-open against master if you want to see this through.

andrewrk avatar Jan 27 '23 07:01 andrewrk

I don't have a need for this anymore, so anyone else who needs it can feel free to pick this up again if they want to.

N00byEdge avatar Jan 27 '23 13:01 N00byEdge