Skip to content

Commit 18bc257

Browse files
committed
Fix clippy warnings
1 parent 9eacf68 commit 18bc257

File tree

1 file changed

+28
-32
lines changed

1 file changed

+28
-32
lines changed

src/lib.rs

+28-32
Original file line numberDiff line numberDiff line change
@@ -351,14 +351,14 @@ impl<'a, T: 'a, const N: usize> DoubleEndedIterator for Drain<'a, T, N> {
351351
}
352352
}
353353

354-
impl<'a, T, const N: usize> ExactSizeIterator for Drain<'a, T, N> {
354+
impl<T, const N: usize> ExactSizeIterator for Drain<'_, T, N> {
355355
#[inline]
356356
fn len(&self) -> usize {
357357
self.iter.len()
358358
}
359359
}
360360

361-
impl<'a, T, const N: usize> core::iter::FusedIterator for Drain<'a, T, N> {}
361+
impl<T, const N: usize> core::iter::FusedIterator for Drain<'_, T, N> {}
362362

363363
impl<'a, T: 'a, const N: usize> Drop for Drain<'a, T, N> {
364364
fn drop(&mut self) {
@@ -1335,7 +1335,7 @@ impl<T, const N: usize> SmallVec<T, N> {
13351335
if !f(&mut *ptr.add(i)) {
13361336
del += 1;
13371337
} else if del > 0 {
1338-
core::mem::swap(&mut *ptr.add(i), &mut *ptr.add(i - del));
1338+
core::ptr::swap(ptr.add(i), ptr.add(i - del));
13391339
}
13401340
}
13411341
}
@@ -1386,7 +1386,7 @@ impl<T, const N: usize> SmallVec<T, N> {
13861386
if !same_bucket(&mut *p_r, &mut *p_wm1) {
13871387
if r != w {
13881388
let p_w = p_wm1.add(1);
1389-
core::mem::swap(&mut *p_r, &mut *p_w);
1389+
core::ptr::swap(p_r, p_w);
13901390
}
13911391
w += 1;
13921392
}
@@ -1449,39 +1449,35 @@ impl<T, const N: usize> SmallVec<T, N> {
14491449
/// # Examples
14501450
///
14511451
/// ```
1452-
/// use std::mem;
1453-
/// use std::ptr;
14541452
/// use smallvec::{SmallVec, smallvec};
14551453
///
1456-
/// fn main() {
1457-
/// let mut v: SmallVec<_, 1> = smallvec![1, 2, 3];
1454+
/// let mut v: SmallVec<_, 1> = smallvec![1, 2, 3];
14581455
///
1459-
/// // Pull out the important parts of `v`.
1460-
/// let p = v.as_mut_ptr();
1461-
/// let len = v.len();
1462-
/// let cap = v.capacity();
1463-
/// let spilled = v.spilled();
1456+
/// // Pull out the important parts of `v`.
1457+
/// let p = v.as_mut_ptr();
1458+
/// let len = v.len();
1459+
/// let cap = v.capacity();
1460+
/// let spilled = v.spilled();
14641461
///
1465-
/// unsafe {
1466-
/// // Forget all about `v`. The heap allocation that stored the
1467-
/// // three values won't be deallocated.
1468-
/// mem::forget(v);
1462+
/// unsafe {
1463+
/// // Forget all about `v`. The heap allocation that stored the
1464+
/// // three values won't be deallocated.
1465+
/// std::mem::forget(v);
14691466
///
1470-
/// // Overwrite memory with [4, 5, 6].
1471-
/// //
1472-
/// // This is only safe if `spilled` is true! Otherwise, we are
1473-
/// // writing into the old `SmallVec`'s inline storage on the
1474-
/// // stack.
1475-
/// assert!(spilled);
1476-
/// for i in 0..len {
1477-
/// ptr::write(p.add(i), 4 + i);
1478-
/// }
1479-
///
1480-
/// // Put everything back together into a SmallVec with a different
1481-
/// // amount of inline storage, but which is still less than `cap`.
1482-
/// let rebuilt = SmallVec::<_, 2>::from_raw_parts(p, len, cap);
1483-
/// assert_eq!(&*rebuilt, &[4, 5, 6]);
1467+
/// // Overwrite memory with [4, 5, 6].
1468+
/// //
1469+
/// // This is only safe if `spilled` is true! Otherwise, we are
1470+
/// // writing into the old `SmallVec`'s inline storage on the
1471+
/// // stack.
1472+
/// assert!(spilled);
1473+
/// for i in 0..len {
1474+
/// std::ptr::write(p.add(i), 4 + i);
14841475
/// }
1476+
///
1477+
/// // Put everything back together into a SmallVec with a different
1478+
/// // amount of inline storage, but which is still less than `cap`.
1479+
/// let rebuilt = SmallVec::<_, 2>::from_raw_parts(p, len, cap);
1480+
/// assert_eq!(&*rebuilt, &[4, 5, 6]);
14851481
/// }
14861482
/// ```
14871483
#[inline]
@@ -2108,7 +2104,7 @@ impl<T: Debug, const N: usize> Debug for IntoIter<T, N> {
21082104
}
21092105
}
21102106

2111-
impl<'a, T: Debug, const N: usize> Debug for Drain<'a, T, N> {
2107+
impl<T: Debug, const N: usize> Debug for Drain<'_, T, N> {
21122108
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
21132109
f.debug_tuple("Drain").field(&self.iter.as_slice()).finish()
21142110
}

0 commit comments

Comments
 (0)