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

Declare a BitVector in a struct #32

Closed
FedericoPonzi opened this issue Dec 1, 2019 · 2 comments
Closed

Declare a BitVector in a struct #32

FedericoPonzi opened this issue Dec 1, 2019 · 2 comments

Comments

@FedericoPonzi
Copy link

Hello,
Is it possible to declare a BitVector of a certain dimension in a struct?
Like [bool; 5] for a 5 bit value. I think I could just declare it as BitVector and that should work, but I also would like to enforce the length of the vector. Is this possible?
Thanks

@myrrlyn
Copy link
Collaborator

myrrlyn commented Dec 1, 2019

Currently there is no array type with static sizing in the crate. The best way to accomplish this is with a Rust value such as u8 and a method which produces a &BitSlice reference over it.

I don't have a good concept for statically sized slices yet.

@myrrlyn
Copy link
Collaborator

myrrlyn commented Dec 11, 2019

I'm going to close this as "impossible in the current language"; bitvec operates by storing information in pointers, because the type system does not allow me to encode information in it. The current unstable implementation of const generics looks like I will be able to make types such as BitSlice<O, T, const START, const LEN> that correctly manage direct memory locations, but until that stabilizes, bitvec has no way of representing these types.

@myrrlyn myrrlyn closed this as completed Dec 11, 2019
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

2 participants