mirror of
https://codeberg.org/icewind/bitbuffer.git
synced 2026-06-03 16:44:06 +02:00
dont panic when reading 0 length signed int
This commit is contained in:
parent
aa42c955ce
commit
7e4830c66f
1 changed files with 3 additions and 1 deletions
|
|
@ -304,7 +304,9 @@ where
|
||||||
where
|
where
|
||||||
T: PrimInt + BitOrAssign + IsSigned + UncheckedPrimitiveInt + BitXor,
|
T: PrimInt + BitOrAssign + IsSigned + UncheckedPrimitiveInt + BitXor,
|
||||||
{
|
{
|
||||||
if T::is_signed() {
|
if count == 0 {
|
||||||
|
T::zero()
|
||||||
|
} else if T::is_signed() {
|
||||||
let sign_bit = value >> (count - 1) & T::one();
|
let sign_bit = value >> (count - 1) & T::one();
|
||||||
if sign_bit == T::one() {
|
if sign_bit == T::one() {
|
||||||
value | (T::zero() - T::one()) ^ ((T::one() << count) - T::one())
|
value | (T::zero() - T::one()) ^ ((T::one() << count) - T::one())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue