Skip to content

Commit c764960

Browse files
committed
Buf and MutableBuf: these functions are not unsafe
1 parent f16c79e commit c764960

File tree

1 file changed

+0
-12
lines changed

1 file changed

+0
-12
lines changed

src/core/buffer.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,12 @@ pub trait Buffer {
1313
fn as_ngx_buf_mut(&mut self) -> *mut ngx_buf_t;
1414

1515
/// Returns the buffer contents as a byte slice.
16-
///
17-
/// # Safety
18-
/// This function is marked as unsafe because it involves raw pointer manipulation.
1916
fn as_bytes(&self) -> &[u8] {
2017
let buf = self.as_ngx_buf();
2118
unsafe { slice::from_raw_parts((*buf).pos, self.len()) }
2219
}
2320

2421
/// Returns the length of the buffer contents.
25-
///
26-
/// # Safety
27-
/// This function is marked as unsafe because it involves raw pointer manipulation.
2822
fn len(&self) -> usize {
2923
let buf = self.as_ngx_buf();
3024
unsafe {
@@ -68,9 +62,6 @@ pub trait Buffer {
6862
/// The `MutableBuffer` trait extends the `Buffer` trait and provides methods for working with a mutable buffer.
6963
pub trait MutableBuffer: Buffer {
7064
/// Returns a mutable reference to the buffer contents as a byte slice.
71-
///
72-
/// # Safety
73-
/// This function is marked as unsafe because it involves raw pointer manipulation.
7465
fn as_bytes_mut(&mut self) -> &mut [u8] {
7566
let buf = self.as_ngx_buf_mut();
7667
unsafe { slice::from_raw_parts_mut((*buf).pos, self.len()) }
@@ -105,9 +96,6 @@ impl Buffer for TemporaryBuffer {
10596

10697
impl MutableBuffer for TemporaryBuffer {
10798
/// Returns a mutable reference to the buffer contents as a byte slice.
108-
///
109-
/// # Safety
110-
/// This function is marked as unsafe because it involves raw pointer manipulation.
11199
fn as_bytes_mut(&mut self) -> &mut [u8] {
112100
unsafe { slice::from_raw_parts_mut((*self.0).pos, self.len()) }
113101
}

0 commit comments

Comments
 (0)