mirror of
https://codeberg.org/icewind/bitbuffer.git
synced 2026-06-03 16:44:06 +02:00
minor read bool improvement
This commit is contained in:
parent
94bc320add
commit
5bd8313a51
1 changed files with 2 additions and 3 deletions
|
|
@ -293,8 +293,7 @@ where
|
|||
let byte_index = position / 8;
|
||||
let bit_offset = position & 7;
|
||||
|
||||
if position < self.bit_len() {
|
||||
let byte = self.slice[byte_index];
|
||||
if let Some(byte) = self.slice.get(byte_index) {
|
||||
if E::is_le() {
|
||||
let shifted = byte >> bit_offset as u8;
|
||||
Ok(shifted & 1u8 == 1)
|
||||
|
|
@ -305,7 +304,7 @@ where
|
|||
} else {
|
||||
Err(BitError::NotEnoughData {
|
||||
requested: 1,
|
||||
bits_left: self.bit_len().saturating_sub(position),
|
||||
bits_left: 0,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue