Giter VIP home page Giter VIP logo

Comments (3)

myrrlyn avatar myrrlyn commented on June 1, 2024 1

Thanks for the report!

You are correct, this is not intended behavior. This is a result of premature optimization on my part in the implementation of BitVec<C, T>::from_bitslice. I had implemented it as cloning the underlying element slice, but the correct behavior is to collect the bits of the source bitslice into a new bitvector.

I have added the following test case,

let bv = bitvec![
	0, 0, 0, 0,
	0, 0, 0, 1,
	1, 0, 0, 0,
	0, 0, 0, 1,
];

let slice = &bv[4 .. 12];
assert_eq!(slice.len(), 8);
assert!(!slice[0]);
assert!(slice[3]);
assert!(slice[4]);
assert!(!slice[7]);

let bv2 = slice.to_owned();
assert_eq!(bv2, slice);
assert!(!bv2[0]);
assert!(bv2[3]);
assert!(bv2[4]);
assert!(!bv2[7]);

to demonstrate correct behavior.

from bitvec.

overminder avatar overminder commented on June 1, 2024 1

That was super fast! Thanks for your fix :)

from bitvec.

myrrlyn avatar myrrlyn commented on June 1, 2024

I had to force-push an amended commit, make sure you're using 82563fe.

from bitvec.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.