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

Implement bit-wise traits? #33

Open
jbaiter opened this issue Jan 30, 2016 · 2 comments
Open

Implement bit-wise traits? #33

jbaiter opened this issue Jan 30, 2016 · 2 comments

Comments

@jbaiter
Copy link

jbaiter commented Jan 30, 2016

I'm currently trying to implement a few bit-parallel algorithms in Rust that I planned to use the BitVec type for. I frequently have to use bit-wise operations (|,&,^,<<,>>) on the bit vectors and was a bit disappointed that only &, | and ^ are supported, and that only as in-place operations via union, difference and intersection. Shifting is currently not supported at all.

Is there a specific reason why the bit-wise traits for these operations from std::ops (BitAnd, Shl, etc) are not implemented for this type? If not, would there be interest in a PR that implements them?

@Gankra
Copy link
Contributor

Gankra commented Feb 3, 2016

I'm not fundamentally opposed, but they seem like terribly expensive things to do by-value. What's your use-case look like? Are you sure you want to be making that many allocations?

@vcque
Copy link

vcque commented Mar 5, 2016

Hi !

I second the need of shift operations. A use case would be : if a bitvec represents possible moves on a board, >> 1 would represent the set of adjacent moves.

About the allocation, I think implementing the assign operations shl_assign, shr_assign do not incur additional allocations. Would it be better to implement shift that way ?

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

No branches or pull requests

3 participants