Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Bitwise operation derives #197

Open
Davoodeh opened this issue Aug 28, 2022 · 3 comments
Open

Feature: Bitwise operation derives #197

Davoodeh opened this issue Aug 28, 2022 · 3 comments

Comments

@Davoodeh
Copy link

Davoodeh commented Aug 28, 2022

Hello and thanks for the great work to every contributor.

I was thinking, however rare, but maybe bitwise derives are missing for custom flag types (unnamed structs of bools or even vec/array of bools or something like that).
Nothing fancy, but maybe for starters we can have some examples like below:

Proposed derives:

  • BitwiseAnd
  • BitwiseOr
  • BitwiseXor
  • BitwiseBool = BitwiseAnd + BitwiseOr + BitwiseXor

I'll be happy to contribute it myself however I am actually not certain about the quality of my code in Rust yet and also the package seems a bit over complicate and without a newbie friendly contribution guide.

Here is an example implementation: https://github.com/Davoodeh/bitwise/blob/master/src/lib.rs

@tyranron
Copy link
Collaborator

tyranron commented Sep 9, 2022

@Davoodeh I'm not against having such derives in derive_more, but somewhat opposed to Bitwise* naming. As for me, it would be nice to preserve granularity and naming from std, in the manner we do for other traits.

@JelteF @ilslv what would you say?

@ilslv
Copy link
Contributor

ilslv commented Sep 9, 2022

@tyranron agreed, I would like for all derive macros having exact std trait name match.

@Davoodeh
Copy link
Author

Thank you for responding.

I have no comment on the naming. Just thought I introduce the idea. The rest of the hard work is for the contributors :D

I also implemented a full version here which has support for boolean fields or an array field or a vector field:
https://github.com/Davoodeh/bitwise/blob/master/src/lib.rs

It's messy but might be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants