ayourtch / vpp-api-encoding

TEMP: vpp api encoding related stuff
0 stars 2 forks source link

add contains to flags #3

Open pepinns opened 2 years ago

pepinns commented 2 years ago

example: if interface.flags.contains(NatConfigFlags::NAT_IS_INSIDE) {

I couldn't find another way to compare if a given flag is in a set, but this method seems most discoverable and ergonomic for developers.

We can do this with a function named contains on the EnumFlag<T>, which just delegates to self.0.contains as long as we implement PartialEq for the Enums. (T) in this case.

This is another case where I have to change 2 repos to make this work. vpp-api-gen ( derive PartialEq), and vpp-api-encoding ( impl contains for EnumFlag where T is PartailEq.

I have 2 patches I'll push up for review.

pepinns commented 2 years ago

re: #4

Adds contains implementation, requires Enums derive PartialEq to work though.