From 136bbcf2463b1a5f020927f92b8ec1af27d7310b Mon Sep 17 00:00:00 2001 From: Yu Li Date: Wed, 9 Jul 2025 21:37:52 +0800 Subject: [PATCH 1/4] chore: remove `mut` for `io_slice` Signed-off-by: Yu Li --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 0cab5c4..88a752f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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(); From ac3430acd0ed5483e2061c6398e728b7207e3229 Mon Sep 17 00:00:00 2001 From: Yu Li Date: Thu, 10 Jul 2025 11:21:30 +0800 Subject: [PATCH 2/4] chore: fix clippy warning `unnecessary_cast` Signed-off-by: Yu Li --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 88a752f..01ee1be 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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!( From f09f43c9697dff24f5d6fe8529c5a1040d6eefc5 Mon Sep 17 00:00:00 2001 From: Yu Li Date: Thu, 10 Jul 2025 11:23:16 +0800 Subject: [PATCH 3/4] chore: change `bytes` and `bytes_mut` to be const fn Signed-off-by: Yu Li --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 01ee1be..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 } From 68e1113300218b3a65b3476bd2392b33f780bcee Mon Sep 17 00:00:00 2001 From: Yu Li Date: Thu, 10 Jul 2025 11:25:04 +0800 Subject: [PATCH 4/4] chore: bump to 0.1.13 Signed-off-by: Yu Li --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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"] }