Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
Added set_len method to Buffer (#1374)
Browse files Browse the repository at this point in the history
Adding `set_len` enables to change the length value of the buffer.

This is required if `get_mut` changes the length of the buffer.
  • Loading branch information
haixuanTao committed Mar 7, 2023
1 parent ac1dfaf commit f258a3e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/buffer/immutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ impl<T> Buffer<T> {
self.offset
}

/// # Safety
/// The caller must ensure that the buffer was properly initialized up to `len`.
#[inline]
pub unsafe fn set_len(&mut self, len: usize) {
self.length = len;
}

/// Returns a mutable reference to its underlying [`Vec`], if possible.
///
/// This operation returns [`Either::Right`] iff this [`Buffer`]:
Expand Down

0 comments on commit f258a3e

Please sign in to comment.