1
0
Fork 0
mirror of https://codeberg.org/icewind/bitbuffer.git synced 2026-06-03 16:44:06 +02:00

Merge pull request #6 from hussein-aitlahcen/master

fixup: decrement before indexing with `last_mut`
This commit is contained in:
Robin Appelman 2024-04-03 19:45:35 +02:00 committed by GitHub
commit 7422800014
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 20 additions and 3 deletions

View file

@ -88,7 +88,8 @@ pub use write::{BitWrite, BitWriteSized};
pub use writestream::BitWriteStream;
mod endianness;
mod num_traits;
#[allow(missing_docs)]
pub mod num_traits;
mod read;
mod readbuffer;
mod readstream;

View file

@ -209,7 +209,7 @@ impl<'a, T: BitWrite<E> + ToOwned + ?Sized, E: Endianness> BitWrite<E> for Cow<'
macro_rules! impl_write_tuple {
($($i:tt: $type:ident),*) => {
impl<'a, E: Endianness, $($type: BitWrite<E>),*> BitWrite<E> for ($($type),*) {
impl<E: Endianness, $($type: BitWrite<E>),*> BitWrite<E> for ($($type),*) {
#[inline]
fn write(&self, stream: &mut BitWriteStream<E>) -> Result<()> {
$(self.$i.write(stream)?;)*

View file

@ -45,7 +45,7 @@ impl<'a> WriteData<'a> {
fn last_mut(&mut self) -> Option<&mut u8> {
match self {
WriteData::Vec(vec) => vec.last_mut(),
WriteData::Slice { data, length } if *length > 0 => Some(&mut data[*length]),
WriteData::Slice { data, length } if *length > 0 => Some(&mut data[*length - 1]),
_ => None,
}
}