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

Difference between BitVec and BitVec<T, O>? #234

Open
avdb13 opened this issue Jul 17, 2023 · 1 comment
Open

Difference between BitVec and BitVec<T, O>? #234

avdb13 opened this issue Jul 17, 2023 · 1 comment

Comments

@avdb13
Copy link

avdb13 commented Jul 17, 2023

The following compiles:

pub struct BitMap {
    inner: Receiver<Vec<u8>>,
    rare_bits: BitVec<u8, Msb0>,
}

impl BitMap {
    async fn recv(&mut self) {
        let next = self.inner.recv().await.unwrap();
        let rhs = BitVec::from_vec(next);

        self.rare_bits.bitxor_assign(rhs);
    }
}

But the following doesn't:

pub struct BitMap {
    inner: Receiver<Vec<u8>>,
    rare_bits: BitVec,
}

impl BitMap {
    async fn recv(&mut self) {
        let next = self.inner.recv().await.unwrap();
        let rhs = BitVec::from_vec(next);

       // no implementation for `BitSlice ^= BitVec<u8, _>`
        self.rare_bits.bitxor_assign(rhs);
    }
}

What are the semantic differences here?

@avdb13 avdb13 changed the title Difference between BitVec and BitVec<T, O>`? Difference between BitVec and BitVec<T, O>? Jul 17, 2023
@mina86
Copy link

mina86 commented Dec 4, 2023

The default is to use usize and Lsb0 so in the second example rare_bits is of type BitVec<usize, Lsb0>.

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