mirror of
https://codeberg.org/icewind/bitbuffer.git
synced 2026-06-03 16:44:06 +02:00
write tuple
This commit is contained in:
parent
1fadf092cf
commit
89f9e4f0af
2 changed files with 22 additions and 0 deletions
16
src/write.rs
16
src/write.rs
|
|
@ -81,6 +81,22 @@ impl<E: Endianness, T: BitWrite<E>, const N: usize> BitWrite<E> for [T; N] {
|
|||
}
|
||||
}
|
||||
|
||||
macro_rules! impl_write_tuple {
|
||||
($($i:tt: $type:ident),*) => {
|
||||
impl<'a, E: Endianness, $($type: BitWrite<E>),*> BitWrite<E> for ($($type),*) {
|
||||
#[inline]
|
||||
fn write(&self, stream: &mut BitWriteStream<E>) -> Result<()> {
|
||||
$(self.$i.write(stream)?;)*
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
impl_write_tuple!(0: T1, 1: T2);
|
||||
impl_write_tuple!(0: T1, 1: T2, 2: T3);
|
||||
impl_write_tuple!(0: T1, 1: T2, 2: T3, 3: T4);
|
||||
|
||||
/// Trait for types that can be written to a stream, requiring the size to be configured
|
||||
pub trait BitWriteSized<E: Endianness> {
|
||||
/// Write the type to stream
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue