Skip to content

Commit

Permalink
removed unnecessary lifetimes
Browse files Browse the repository at this point in the history
  • Loading branch information
matko committed Sep 15, 2023
1 parent d2504ae commit 8130695
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/structure/adjacencylist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ pub async fn adjacency_list_stream_pairs<F: 'static + FileLoad>(
}

pub struct UnindexedAdjacencyListBufBuilder {
bitarray: BitArrayBufBuilder<'static, BytesMut>,
nums: LogArrayBufBuilder<'static, BytesMut>,
bitarray: BitArrayBufBuilder<BytesMut>,
nums: LogArrayBufBuilder<BytesMut>,
last_left: u64,
last_right: u64,
}
Expand Down
16 changes: 6 additions & 10 deletions src/structure/bitarray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,23 +200,21 @@ impl BitArray {
}
}

pub struct BitArrayBufBuilder<'a, B: 'a> {
pub struct BitArrayBufBuilder<B> {
/// Destination of the bit array data.
dest: B,
/// Storage for the next word to be written.
current: u64,
/// Number of bits written to the buffer
count: u64,
_x: std::marker::PhantomData<&'a ()>,
}

impl<'a, B: BufMut + 'a> BitArrayBufBuilder<'a, B> {
pub fn new(dest: B) -> BitArrayBufBuilder<'a, B> {
impl<B: BufMut> BitArrayBufBuilder<B> {
pub fn new(dest: B) -> BitArrayBufBuilder<B> {
BitArrayBufBuilder {
dest,
current: 0,
count: 0,
_x: Default::default(),
}
}

Expand Down Expand Up @@ -383,21 +381,19 @@ pub fn bitarray_stream_blocks<R: AsyncRead + Unpin>(r: R) -> FramedRead<R, BitAr
FramedRead::new(r, BitArrayBlockDecoder { readahead: None })
}

pub fn bitarray_iter_blocks<'a, B: Buf + 'a>(b: B) -> BitArrayBlockIterator<'a, B> {
pub fn bitarray_iter_blocks<B: Buf>(b: B) -> BitArrayBlockIterator<B> {
BitArrayBlockIterator {
buf: b,
readahead: None,
_x: Default::default(),
}
}

pub struct BitArrayBlockIterator<'a, B: Buf + 'a> {
pub struct BitArrayBlockIterator<B: Buf> {
buf: B,
readahead: Option<u64>,
_x: std::marker::PhantomData<&'a ()>,
}

impl<'a, B: Buf> Iterator for BitArrayBlockIterator<'a, B> {
impl<B: Buf> Iterator for BitArrayBlockIterator<B> {
type Item = u64;
fn next(&mut self) -> Option<u64> {
decode_next_bitarray_block(&mut self.buf, &mut self.readahead)
Expand Down
9 changes: 4 additions & 5 deletions src/structure/bitindex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,12 +438,11 @@ pub async fn build_bitindex<
}

pub fn build_bitindex_from_block_iter<
'a,
I: Iterator<Item = u64>,
B1: BufMut + 'a,
B2: BufMut + 'a,
B1: BufMut,
B2: BufMut,
>(
blocks_iter: &'a mut I,
blocks_iter: I,
blocks: B1,
sblocks: B2,
) {
Expand Down Expand Up @@ -478,7 +477,7 @@ pub fn build_bitindex_from_block_iter<
sblocks_builder.finalize();
}

pub fn build_bitindex_from_buf<'a, B1: Buf + 'a, B2: BufMut + 'a, B3: BufMut + 'a>(
pub fn build_bitindex_from_buf<B1: Buf, B2: BufMut, B3: BufMut>(
bitarray: B1,
blocks: B2,
sblocks: B3,
Expand Down
8 changes: 3 additions & 5 deletions src/structure/logarray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ impl LogArray {
}

/// write a logarray directly to an AsyncWrite
pub struct LogArrayBufBuilder<'a, B: BufMut + 'a> {
pub struct LogArrayBufBuilder<B: BufMut> {
/// Destination of the log array data
buf: B,
/// Bit width of an element
Expand All @@ -415,16 +415,15 @@ pub struct LogArrayBufBuilder<'a, B: BufMut + 'a> {
offset: u8,
/// Number of elements written to the buffer
count: u64,
_x: std::marker::PhantomData<&'a ()>,
}

impl<'a, D: std::ops::DerefMut<Target = BytesMut> + BufMut> LogArrayBufBuilder<'a, D> {
impl<D: std::ops::DerefMut<Target = BytesMut> + BufMut> LogArrayBufBuilder<D> {
pub fn reserve(&mut self, additional: usize) {
self.buf.reserve(additional * self.width as usize / 8);
}
}

impl<'a, B: BufMut + 'a> LogArrayBufBuilder<'a, B> {
impl<B: BufMut> LogArrayBufBuilder<B> {
pub fn new(buf: B, width: u8) -> Self {
Self {
buf,
Expand All @@ -435,7 +434,6 @@ impl<'a, B: BufMut + 'a> LogArrayBufBuilder<'a, B> {
offset: 0,
// No elements have been written.
count: 0,
_x: Default::default(),
}
}

Expand Down

0 comments on commit 8130695

Please sign in to comment.