Skip to content

Commit 16132ad

Browse files
Fix latest clippy warnings (#787)
1 parent 3e44f88 commit 16132ad

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/bytes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ impl PartialEq for Bytes {
789789

790790
impl PartialOrd for Bytes {
791791
fn partial_cmp(&self, other: &Bytes) -> Option<cmp::Ordering> {
792-
self.as_slice().partial_cmp(other.as_slice())
792+
Some(self.cmp(other))
793793
}
794794
}
795795

@@ -1536,7 +1536,7 @@ unsafe fn shallow_clone_vec(
15361536
// pointed to by `actual` will be visible.
15371537
match atom.compare_exchange(ptr as _, shared as _, Ordering::AcqRel, Ordering::Acquire) {
15381538
Ok(actual) => {
1539-
debug_assert!(actual as usize == ptr as usize);
1539+
debug_assert!(core::ptr::eq(actual, ptr));
15401540
// The upgrade was successful, the new handle can be
15411541
// returned.
15421542
Bytes {

src/bytes_mut.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ impl BytesMut {
779779
self.ptr = vptr(v.as_mut_ptr());
780780
self.cap = v.capacity();
781781
debug_assert_eq!(self.len, v.len());
782-
return true;
782+
true
783783
}
784784

785785
/// Attempts to cheaply reclaim already allocated capacity for at least `additional` more
@@ -985,7 +985,7 @@ impl BytesMut {
985985
// new start and updating the `len` field to reflect the new length
986986
// of the view.
987987
self.ptr = vptr(self.ptr.as_ptr().add(count));
988-
self.len = self.len.checked_sub(count).unwrap_or(0);
988+
self.len = self.len.saturating_sub(count);
989989
self.cap -= count;
990990
}
991991

@@ -1283,7 +1283,7 @@ impl PartialEq for BytesMut {
12831283

12841284
impl PartialOrd for BytesMut {
12851285
fn partial_cmp(&self, other: &BytesMut) -> Option<cmp::Ordering> {
1286-
self.as_slice().partial_cmp(other.as_slice())
1286+
Some(self.cmp(other))
12871287
}
12881288
}
12891289

@@ -1718,7 +1718,7 @@ impl From<BytesMut> for Vec<u8> {
17181718
rebuild_vec(bytes.ptr.as_ptr(), bytes.len, bytes.cap, off)
17191719
}
17201720
} else {
1721-
let shared = bytes.data as *mut Shared;
1721+
let shared = bytes.data;
17221722

17231723
if unsafe { (*shared).is_unique() } {
17241724
let vec = core::mem::take(unsafe { &mut (*shared).vec });

tests/test_chain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ fn vectored_read() {
135135

136136
#[test]
137137
fn chain_growing_buffer() {
138-
let mut buff = [' ' as u8; 10];
138+
let mut buff = [b' '; 10];
139139
let mut vec = b"wassup".to_vec();
140140

141141
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

0 commit comments

Comments
 (0)