mirror of
https://codeberg.org/icewind/bitbuffer.git
synced 2026-06-04 00:54:07 +02:00
add BitRead implementations for Rc/Arc
This commit is contained in:
parent
c3709e57d8
commit
5856dd3ade
1 changed files with 16 additions and 0 deletions
16
src/read.rs
16
src/read.rs
|
|
@ -5,6 +5,8 @@ use std::collections::HashMap;
|
|||
use std::hash::Hash;
|
||||
use std::marker::PhantomData;
|
||||
use std::mem::size_of;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Trait for types that can be read from a stream without requiring the size to be configured
|
||||
///
|
||||
|
|
@ -222,6 +224,20 @@ impl<E: Endianness> BitRead<E> for String {
|
|||
}
|
||||
}
|
||||
|
||||
impl<E: Endianness, T: BitRead<E>> BitRead<E> for Rc<T> {
|
||||
#[inline]
|
||||
fn read(stream: &mut BitStream<E>) -> Result<Self> {
|
||||
Ok(Rc::new(T::read(stream)?))
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: Endianness, T: BitRead<E>> BitRead<E> for Arc<T> {
|
||||
#[inline]
|
||||
fn read(stream: &mut BitStream<E>) -> Result<Self> {
|
||||
Ok(Arc::new(T::read(stream)?))
|
||||
}
|
||||
}
|
||||
|
||||
/// Trait for types that can be read from a stream, requiring the size to be configured
|
||||
///
|
||||
/// The meaning of the set sized depends on the type being read (e.g, number of bits for integers,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue