mirror of
https://codeberg.org/icewind/bitbuffer.git
synced 2026-06-03 08:34:07 +02:00
intoiter
This commit is contained in:
parent
5008cae35d
commit
bc5d74038e
2 changed files with 8 additions and 5 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
name = "bitbuffer"
|
name = "bitbuffer"
|
||||||
version = "0.10.3"
|
version = "0.10.3"
|
||||||
authors = ["Robin Appelman <robin@icewind.nl>"]
|
authors = ["Robin Appelman <robin@icewind.nl>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
description = "Reading bit sequences from a byte slice"
|
description = "Reading bit sequences from a byte slice"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
repository = "https://github.com/icewind1991/bitbuffer"
|
repository = "https://github.com/icewind1991/bitbuffer"
|
||||||
|
|
|
||||||
|
|
@ -290,7 +290,7 @@ macro_rules! impl_split_fit {
|
||||||
|
|
||||||
fn split_fit_usize<E: Endianness>(self) -> Self::Iter {
|
fn split_fit_usize<E: Endianness>(self) -> Self::Iter {
|
||||||
assert!(size_of::<Self>() < size_of::<usize>());
|
assert!(size_of::<Self>() < size_of::<usize>());
|
||||||
Self::Iter::new([(self as usize, size_of::<Self>() as u8 * 8)])
|
[(self as usize, size_of::<Self>() as u8 * 8)].into_iter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -341,7 +341,7 @@ impl SplitFitUsize for u64 {
|
||||||
type Iter = array::IntoIter<(usize, u8), 3>;
|
type Iter = array::IntoIter<(usize, u8), 3>;
|
||||||
|
|
||||||
fn split_fit_usize<E: Endianness>(self) -> Self::Iter {
|
fn split_fit_usize<E: Endianness>(self) -> Self::Iter {
|
||||||
Self::Iter::new(if E::is_le() {
|
(if E::is_le() {
|
||||||
[
|
[
|
||||||
((self & (Self::MAX >> 40)) as usize, 24),
|
((self & (Self::MAX >> 40)) as usize, 24),
|
||||||
((self >> 24 & (Self::MAX >> 16)) as usize, 24),
|
((self >> 24 & (Self::MAX >> 16)) as usize, 24),
|
||||||
|
|
@ -354,6 +354,7 @@ impl SplitFitUsize for u64 {
|
||||||
((self & (Self::MAX >> 40)) as usize, 24),
|
((self & (Self::MAX >> 40)) as usize, 24),
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
.into_iter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -363,7 +364,7 @@ impl SplitFitUsize for u128 {
|
||||||
type Iter = array::IntoIter<(usize, u8), 6>;
|
type Iter = array::IntoIter<(usize, u8), 6>;
|
||||||
|
|
||||||
fn split_fit_usize<E: Endianness>(self) -> Self::Iter {
|
fn split_fit_usize<E: Endianness>(self) -> Self::Iter {
|
||||||
Self::Iter::new(if E::is_le() {
|
(if E::is_le() {
|
||||||
[
|
[
|
||||||
((self & (Self::MAX >> 104)) as usize, 24),
|
((self & (Self::MAX >> 104)) as usize, 24),
|
||||||
((self >> 24 & (Self::MAX >> 80)) as usize, 24),
|
((self >> 24 & (Self::MAX >> 80)) as usize, 24),
|
||||||
|
|
@ -382,6 +383,7 @@ impl SplitFitUsize for u128 {
|
||||||
((self & (Self::MAX >> 104)) as usize, 24),
|
((self & (Self::MAX >> 104)) as usize, 24),
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
.into_iter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -392,7 +394,7 @@ impl SplitFitUsize for usize {
|
||||||
|
|
||||||
fn split_fit_usize<E: Endianness>(self) -> Self::Iter {
|
fn split_fit_usize<E: Endianness>(self) -> Self::Iter {
|
||||||
const USIZE_BITS: usize = size_of::<usize>() * 8;
|
const USIZE_BITS: usize = size_of::<usize>() * 8;
|
||||||
Self::Iter::new(if E::is_le() {
|
(if E::is_le() {
|
||||||
[
|
[
|
||||||
(
|
(
|
||||||
(self & (Self::MAX >> (USIZE_BITS - 8))) as usize,
|
(self & (Self::MAX >> (USIZE_BITS - 8))) as usize,
|
||||||
|
|
@ -409,6 +411,7 @@ impl SplitFitUsize for usize {
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
.into_iter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue