Comments (2)
Hi! I apologize for the long delay; I have had a very stressful winter and have not had the time or energy to check this repository in a timely manner. I'm trying to catch up now.
Okay, so, bitslice[index]
already produces a bool
; you shouldn't need to change its type. But this is definitely a logic error in funty
.
I'll have to fix it in funty 2
, since bitvec 1
is going to keep using that. Thank you for bringing it to my attention.
from bitvec.
I just got bit by this, very confusing!
In my case, I was using as_bool()
because I'm not familiar with BitVec
and some API I'm calling returned BitVec
. I wanted to iterate over the bits, so I did .iter()
, and then I ended up with a BitRef
, and I called as_bool()
on that, causing the problem illustrated by the OP.
For completeness here's my minimal test case:
// use bitvec::prelude::*;
let interrogate_lsb = |x: BitVec<_, _>| {
let lsb_array = x[0];
let lsb_iter_as_bool = x.iter().next().unwrap().as_bool();
let lsb_iter_as_u64 = x.iter().next().unwrap().as_u64();
println!("x: {x:?}");
println!("x[0]: {lsb_array:?}");
println!("x.iter().next().unwrap().as_bool(): {lsb_iter_as_bool:?}");
println!("x.iter().next().unwrap().as_u64(): {lsb_iter_as_u64:?}");
};
let mut bv = bitvec![u8, Lsb0;];
bv.push(false);
interrogate_lsb(bv);
println!();
let mut bv = bitvec![u8, Lsb0;];
bv.push(true);
interrogate_lsb(bv);
which prints
x: BitVec<u8, bitvec::order::Lsb0> { addr: 0x7fc434001f20, head: 000, bits: 1, capacity: 64 } [0]
x[0]: false
x.iter.next().unwrap(): BitRef<u8, bitvec::order::Lsb0> { addr: 0x7fc434001f20, head: 000, bits: 1, bit: false }
x.iter().next().unwrap().as_bool(): true
x.iter().next().unwrap().as_u64(): 0
x: BitVec<u8, bitvec::order::Lsb0> { addr: 0x7fc434001f20, head: 000, bits: 1, capacity: 64 } [1]
x[0]: true
x.iter.next().unwrap(): BitRef<u8, bitvec::order::Lsb0> { addr: 0x7fc434001f20, head: 000, bits: 1, bit: true }
x.iter().next().unwrap().as_bool(): false
x.iter().next().unwrap().as_u64(): 1
from bitvec.
Related Issues (20)
- Use #[track_caller] attribute HOT 2
- Dead documentation link HOT 4
- `to_bitvec` and related functions returning invalid values HOT 3
- `bitvec` contains unsound global state HOT 4
- `chunks_exact_mut()` occasionally doesn't return the last chunk when `step_by()` is involved
- Difference between `BitVec` and `BitVec<T, O>`? HOT 1
- `copy_within` panics on empty range
- `bitarr!` macro link incorrect
- Implement `BitStore` for signed integer types
- impl `TryFrom<BitVec>` for `BitArray`
- How to convert bitvec to slice? HOT 1
- Build for STM32 (no_std, thumbv7m-none-eabi) - no global memory allocator HOT 1
- Regarding the safety of `chunks_mut(...).remove_alias()` HOT 1
- `BitSlice::shift_start` and `BitSlice::shift_end` argument bounds incorrectly documented
- Incorrect handling of end index in BitVec::extend_from_within
- Implement `Send` for `BitValIter`
- How to "not" an entire `BitVec` in place? HOT 1
- Example of zero-initialized BitVec?
- Cargo check failed with error: could not compile `bitvec` (lib) HOT 2
- crate doesnt compile on arduino HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bitvec.