mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-25 00:00:22 +02:00
Fix latest clippy warnings (#787)
This commit is contained in:
+2
-2
@@ -789,7 +789,7 @@ impl PartialEq for Bytes {
|
|||||||
|
|
||||||
impl PartialOrd for Bytes {
|
impl PartialOrd for Bytes {
|
||||||
fn partial_cmp(&self, other: &Bytes) -> Option<cmp::Ordering> {
|
fn partial_cmp(&self, other: &Bytes) -> Option<cmp::Ordering> {
|
||||||
self.as_slice().partial_cmp(other.as_slice())
|
Some(self.cmp(other))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1536,7 +1536,7 @@ unsafe fn shallow_clone_vec(
|
|||||||
// pointed to by `actual` will be visible.
|
// pointed to by `actual` will be visible.
|
||||||
match atom.compare_exchange(ptr as _, shared as _, Ordering::AcqRel, Ordering::Acquire) {
|
match atom.compare_exchange(ptr as _, shared as _, Ordering::AcqRel, Ordering::Acquire) {
|
||||||
Ok(actual) => {
|
Ok(actual) => {
|
||||||
debug_assert!(actual as usize == ptr as usize);
|
debug_assert!(core::ptr::eq(actual, ptr));
|
||||||
// The upgrade was successful, the new handle can be
|
// The upgrade was successful, the new handle can be
|
||||||
// returned.
|
// returned.
|
||||||
Bytes {
|
Bytes {
|
||||||
|
|||||||
+4
-4
@@ -779,7 +779,7 @@ impl BytesMut {
|
|||||||
self.ptr = vptr(v.as_mut_ptr());
|
self.ptr = vptr(v.as_mut_ptr());
|
||||||
self.cap = v.capacity();
|
self.cap = v.capacity();
|
||||||
debug_assert_eq!(self.len, v.len());
|
debug_assert_eq!(self.len, v.len());
|
||||||
return true;
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attempts to cheaply reclaim already allocated capacity for at least `additional` more
|
/// Attempts to cheaply reclaim already allocated capacity for at least `additional` more
|
||||||
@@ -985,7 +985,7 @@ impl BytesMut {
|
|||||||
// new start and updating the `len` field to reflect the new length
|
// new start and updating the `len` field to reflect the new length
|
||||||
// of the view.
|
// of the view.
|
||||||
self.ptr = vptr(self.ptr.as_ptr().add(count));
|
self.ptr = vptr(self.ptr.as_ptr().add(count));
|
||||||
self.len = self.len.checked_sub(count).unwrap_or(0);
|
self.len = self.len.saturating_sub(count);
|
||||||
self.cap -= count;
|
self.cap -= count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1283,7 +1283,7 @@ impl PartialEq for BytesMut {
|
|||||||
|
|
||||||
impl PartialOrd for BytesMut {
|
impl PartialOrd for BytesMut {
|
||||||
fn partial_cmp(&self, other: &BytesMut) -> Option<cmp::Ordering> {
|
fn partial_cmp(&self, other: &BytesMut) -> Option<cmp::Ordering> {
|
||||||
self.as_slice().partial_cmp(other.as_slice())
|
Some(self.cmp(other))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1718,7 +1718,7 @@ impl From<BytesMut> for Vec<u8> {
|
|||||||
rebuild_vec(bytes.ptr.as_ptr(), bytes.len, bytes.cap, off)
|
rebuild_vec(bytes.ptr.as_ptr(), bytes.len, bytes.cap, off)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let shared = bytes.data as *mut Shared;
|
let shared = bytes.data;
|
||||||
|
|
||||||
if unsafe { (*shared).is_unique() } {
|
if unsafe { (*shared).is_unique() } {
|
||||||
let vec = core::mem::take(unsafe { &mut (*shared).vec });
|
let vec = core::mem::take(unsafe { &mut (*shared).vec });
|
||||||
|
|||||||
+1
-1
@@ -135,7 +135,7 @@ fn vectored_read() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn chain_growing_buffer() {
|
fn chain_growing_buffer() {
|
||||||
let mut buff = [' ' as u8; 10];
|
let mut buff = [b' '; 10];
|
||||||
let mut vec = b"wassup".to_vec();
|
let mut vec = b"wassup".to_vec();
|
||||||
|
|
||||||
let mut chained = (&mut buff[..]).chain_mut(&mut vec).chain_mut(Vec::new()); // Required for potential overflow because remaining_mut for Vec is isize::MAX - vec.len(), but for chain_mut is usize::MAX
|
let mut chained = (&mut buff[..]).chain_mut(&mut vec).chain_mut(Vec::new()); // Required for potential overflow because remaining_mut for Vec is isize::MAX - vec.len(), but for chain_mut is usize::MAX
|
||||||
|
|||||||
Reference in New Issue
Block a user