Fix clippy::semicolon_if_nothing_returned warnings

This commit is contained in:
Christian Poveda 2025-03-24 16:21:19 -05:00
parent 1635b7292a
commit 739dbc4c3c
No known key found for this signature in database
GPG Key ID: 3B422F347D81A9E8
17 changed files with 40 additions and 39 deletions

View File

@ -222,7 +222,7 @@ where
/// assert!(heap.is_empty());
/// ```
pub fn clear(&mut self) {
self.data.clear()
self.data.clear();
}
/// Returns the length of the binary heap.

View File

@ -896,7 +896,7 @@ impl<T, S: VecStorage<T> + ?Sized> Extend<T> for DequeInner<T, S> {
}
impl<'a, T: 'a + Copy, S: VecStorage<T> + ?Sized> Extend<&'a T> for DequeInner<T, S> {
fn extend<I: IntoIterator<Item = &'a T>>(&mut self, iter: I) {
self.extend(iter.into_iter().copied())
self.extend(iter.into_iter().copied());
}
}

View File

@ -293,7 +293,7 @@ impl<T, S: HistBufStorage<T> + ?Sized> HistoryBufferInner<T, S> {
ptr::drop_in_place(ptr::slice_from_raw_parts_mut(
self.data.borrow_mut().as_mut_ptr().cast::<T>(),
self.len(),
))
));
}
}
@ -514,7 +514,7 @@ where
where
I: IntoIterator<Item = &'a T>,
{
self.extend(iter.into_iter().cloned())
self.extend(iter.into_iter().cloned());
}
}
@ -818,7 +818,7 @@ mod tests {
assert_eq_iter(
[head, tail].iter().copied().flatten(),
buffer.oldest_ordered(),
)
);
}
}

View File

@ -1298,7 +1298,7 @@ where
where
I: IntoIterator<Item = (&'a K, &'a V)>,
{
self.extend(iterable.into_iter().map(|(&key, &value)| (key, value)))
self.extend(iterable.into_iter().map(|(&key, &value)| (key, value)));
}
}
@ -1481,7 +1481,7 @@ mod tests {
mem::size_of::<u16>() // hash
) + // buckets
mem::size_of::<usize>() // entries.length
)
);
}
#[test]
@ -1673,7 +1673,7 @@ mod tests {
assert_eq!(value, *v.insert(value).unwrap());
}
};
assert_eq!(value, *src.get(&key).unwrap())
assert_eq!(value, *src.get(&key).unwrap());
}
#[test]
@ -1693,7 +1693,7 @@ mod tests {
panic!("Entry not found");
}
};
assert_eq!(value2, *src.get(&key).unwrap())
assert_eq!(value2, *src.get(&key).unwrap());
}
#[test]

View File

@ -212,7 +212,7 @@ impl<T, S, const N: usize> IndexSet<T, S, N> {
/// assert!(v.is_empty());
/// ```
pub fn clear(&mut self) {
self.map.clear()
self.map.clear();
}
}
@ -560,7 +560,7 @@ where
where
I: IntoIterator<Item = T>,
{
self.map.extend(iterable.into_iter().map(|k| (k, ())))
self.map.extend(iterable.into_iter().map(|k| (k, ())));
}
}
@ -573,7 +573,7 @@ where
where
I: IntoIterator<Item = &'a T>,
{
self.extend(iterable.into_iter().cloned())
self.extend(iterable.into_iter().cloned());
}
}

View File

@ -147,6 +147,7 @@
clippy::option_if_let_else,
clippy::ptr_as_ptr,
clippy::doc_markdown,
clippy::semicolon_if_nothing_returned
)]
pub use binary_heap::BinaryHeap;

View File

@ -85,7 +85,7 @@ where
/// assert!(map.is_empty());
/// ```
pub fn clear(&mut self) {
self.buffer.clear()
self.buffer.clear();
}
/// Returns true if the map contains a value for the specified key.

View File

@ -148,7 +148,7 @@ pub trait ArcPool: Sized {
/// Add a statically allocated memory block to the memory pool
fn manage(block: &'static mut ArcBlock<Self::Data>) {
Self::singleton().manage(block)
Self::singleton().manage(block);
}
}
@ -315,7 +315,7 @@ where
where
H: Hasher,
{
(**self).hash(state)
(**self).hash(state);
}
}

View File

@ -166,7 +166,7 @@ pub trait BoxPool: Sized {
/// Add a statically allocated memory block to the memory pool
fn manage(block: &'static mut BoxBlock<Self::Data>) {
Self::singleton().manage(block)
Self::singleton().manage(block);
}
}
@ -259,7 +259,7 @@ where
where
H: Hasher,
{
(**self).hash(state)
(**self).hash(state);
}
}

View File

@ -135,7 +135,7 @@ pub trait ObjectPool: Sized {
/// Adds a statically allocate object to the pool
fn manage(block: &'static mut ObjectBlock<Self::Data>) {
Self::singleton().manage(block)
Self::singleton().manage(block);
}
}
@ -262,7 +262,7 @@ where
where
H: Hasher,
{
(**self).hash(state)
(**self).hash(state);
}
}

View File

@ -27,7 +27,7 @@ where
/// - `node` must be a valid pointer
/// - aliasing rules must be enforced by the caller. e.g, the same `node` may not be pushed more than once
pub unsafe fn push(&self, node: NonNullPtr<N>) {
impl_::push(self, node)
impl_::push(self, node);
}
pub fn try_pop(&self) -> Option<NonNullPtr<N>> {

View File

@ -87,7 +87,7 @@ where
#[inline]
fn store(&self, value: Option<NonNullPtr<N>>, order: Ordering) {
self.inner
.store(value.map(NonNullPtr::into_inner).unwrap_or_default(), order)
.store(value.map(NonNullPtr::into_inner).unwrap_or_default(), order);
}
}

View File

@ -770,7 +770,7 @@ where
/// ```
#[inline]
pub fn finish(self) {
drop(self)
drop(self);
}
}
@ -925,14 +925,14 @@ mod tests {
ll.push(2).unwrap();
ll.push(3).unwrap();
assert!(ll.is_full())
assert!(ll.is_full());
}
#[test]
fn test_empty() {
let ll: SortedLinkedList<u32, LinkedIndexUsize, Max, 3> = SortedLinkedList::new_usize();
assert!(ll.is_empty())
assert!(ll.is_empty());
}
#[test]

View File

@ -308,7 +308,7 @@ impl<T, S: Storage> QueueInner<T, S> {
/// to create a copy of `item`, which could result in `T`'s destructor running on `item`
/// twice.
pub unsafe fn enqueue_unchecked(&mut self, val: T) {
self.inner_enqueue_unchecked(val)
self.inner_enqueue_unchecked(val);
}
// The memory for dequeuing is "owned" by the head pointer,.
@ -678,7 +678,7 @@ impl<T, S: Storage> ProducerInner<'_, T, S> {
/// See [`Queue::enqueue_unchecked`]
#[inline]
pub unsafe fn enqueue_unchecked(&mut self, val: T) {
self.rb.inner_enqueue_unchecked(val)
self.rb.inner_enqueue_unchecked(val);
}
/// Returns if there is any space to enqueue a new item. When this returns true, at

View File

@ -519,7 +519,7 @@ impl<S: VecStorage<u8> + ?Sized> StringInner<S> {
pub fn truncate(&mut self, new_len: usize) {
if new_len <= self.len() {
assert!(self.is_char_boundary(new_len));
self.vec.truncate(new_len)
self.vec.truncate(new_len);
}
}
@ -619,7 +619,7 @@ impl<S: VecStorage<u8> + ?Sized> StringInner<S> {
/// ```
#[inline]
pub fn clear(&mut self) {
self.vec.clear()
self.vec.clear();
}
}
@ -701,7 +701,7 @@ impl<S: VecStorage<u8> + ?Sized> fmt::Display for StringInner<S> {
impl<S: VecStorage<u8> + ?Sized> hash::Hash for StringInner<S> {
#[inline]
fn hash<H: hash::Hasher>(&self, hasher: &mut H) {
<str as hash::Hash>::hash(self, hasher)
<str as hash::Hash>::hash(self, hasher);
}
}
@ -1153,26 +1153,26 @@ mod tests {
let number = 5;
let float = 3.12;
let formatted = format!(15; "{:0>3} plus {float}", number).unwrap();
assert_eq!(formatted, "005 plus 3.12")
assert_eq!(formatted, "005 plus 3.12");
}
#[test]
fn format_inferred_capacity() {
let number = 5;
let float = 3.12;
let formatted: String<15> = format!("{:0>3} plus {float}", number).unwrap();
assert_eq!(formatted, "005 plus 3.12")
assert_eq!(formatted, "005 plus 3.12");
}
#[test]
fn format_overflow() {
let i = 1234567;
let formatted = format!(4; "13{}", i);
assert_eq!(formatted, Err(core::fmt::Error))
assert_eq!(formatted, Err(core::fmt::Error));
}
#[test]
fn format_plain_string_overflow() {
let formatted = format!(2; "123");
assert_eq!(formatted, Err(core::fmt::Error))
assert_eq!(formatted, Err(core::fmt::Error));
}
}

View File

@ -497,7 +497,7 @@ impl<T, S: VecStorage<T> + ?Sized> VecInner<T, S> {
I: IntoIterator<Item = T>,
{
for elem in iter {
self.push(elem).ok().unwrap()
self.push(elem).ok().unwrap();
}
}
@ -753,7 +753,7 @@ impl<T, S: VecStorage<T> + ?Sized> VecInner<T, S> {
pub unsafe fn set_len(&mut self, new_len: usize) {
debug_assert!(new_len <= self.capacity());
self.len = new_len
self.len = new_len;
}
/// Removes an element from the vector and returns it.
@ -1223,7 +1223,7 @@ impl<T, S: VecStorage<T> + ?Sized> Extend<T> for VecInner<T, S> {
where
I: IntoIterator<Item = T>,
{
self.extend(iter)
self.extend(iter);
}
}
@ -1235,7 +1235,7 @@ where
where
I: IntoIterator<Item = &'a T>,
{
self.extend(iter.into_iter().cloned())
self.extend(iter.into_iter().cloned());
}
}
@ -1244,7 +1244,7 @@ where
T: core::hash::Hash,
{
fn hash<H: hash::Hasher>(&self, state: &mut H) {
<[T] as hash::Hash>::hash(self, state)
<[T] as hash::Hash>::hash(self, state);
}
}

View File

@ -229,5 +229,5 @@ fn iterator_properly_wraps() {
for (idx, el) in rb.iter().enumerate() {
actual[idx] = *el;
}
assert_eq!(expected, actual)
assert_eq!(expected, actual);
}