diff --git a/Cargo.toml b/Cargo.toml index fa2ef94..bf3481c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "linkedbytes" -version = "0.1.12" +version = "0.1.13" authors = ["Volo Team "] edition = "2021" description = "LinkedBytes is a linked list of Bytes and BytesMut." @@ -17,5 +17,5 @@ maintenance = { status = "actively-developed" } [dependencies] bytes = "1" -tokio = { version = "1", features = ["io-util"] } faststr = "0.2" +tokio = { version = "1", features = ["io-util"] } diff --git a/src/lib.rs b/src/lib.rs index 0cab5c4..6ee5d47 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -59,12 +59,12 @@ impl LinkedBytes { } #[inline] - pub fn bytes(&self) -> &BytesMut { + pub const fn bytes(&self) -> &BytesMut { &self.bytes } #[inline] - pub fn bytes_mut(&mut self) -> &mut BytesMut { + pub const fn bytes_mut(&mut self) -> &mut BytesMut { &mut self.bytes } @@ -103,7 +103,7 @@ impl LinkedBytes { self.list.push_back(node); } - pub fn io_slice(&mut self) -> Vec> { + pub fn io_slice(&self) -> Vec> { let mut ioslice = Vec::with_capacity(self.list.len() + 1); for node in self.list.iter() { let bytes = node.as_ref(); @@ -233,7 +233,7 @@ impl LinkedBytes { } // adjust the outer [IoSlice] - base_ptr = unsafe { (base_ptr as *mut IoSlice).add(remove) }; + base_ptr = unsafe { base_ptr.add(remove) }; len -= remove; if len == 0 { assert!( @@ -242,7 +242,7 @@ impl LinkedBytes { ); } else { // adjust the inner IoSlice - let inner_slice = unsafe { &mut *(base_ptr as *mut IoSlice) }; + let inner_slice = unsafe { &mut *base_ptr }; let (inner_ptr, inner_len) = (inner_slice.as_ptr(), inner_slice.len()); let remaining = n - accumulated_len; assert!(