Skip to content
This repository was archived by the owner on Nov 27, 2020. It is now read-only.

Commit cefc37f

Browse files
committed
Fix clippy annotations
1 parent 6292d69 commit cefc37f

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/vec.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2066,6 +2066,7 @@ impl<T: Clone, A: ReallocRef> SpecFromElem<A> for T {
20662066
}
20672067
}
20682068

2069+
#[allow(clippy::use_self)]
20692070
impl<A: ReallocRef> SpecFromElem<A> for u8 {
20702071
#[inline]
20712072
fn try_from_elem_in(elem: Self, n: usize, a: A) -> Result<Vec<Self, A>, CollectionAllocErr<A>> {
@@ -2128,11 +2129,11 @@ impl_is_zero!(u64, |x| x == 0);
21282129
impl_is_zero!(u128, |x| x == 0);
21292130
impl_is_zero!(usize, |x| x == 0);
21302131

2131-
impl_is_zero!(bool, |x| x == false);
2132+
impl_is_zero!(bool, |x: Self| !x);
21322133
impl_is_zero!(char, |x| x == '\0');
21332134

2134-
impl_is_zero!(f32, |x: f32| x.to_bits() == 0);
2135-
impl_is_zero!(f64, |x: f64| x.to_bits() == 0);
2135+
impl_is_zero!(f32, |x: Self| x.to_bits() == 0);
2136+
impl_is_zero!(f64, |x: Self| x.to_bits() == 0);
21362137

21372138
unsafe impl<T> IsZero for *const T {
21382139
#[inline]
@@ -2356,10 +2357,10 @@ where
23562357
// vector being full in the few subsequent loop iterations.
23572358
// So we get better branch prediction.
23582359
let mut vector = match iter.next() {
2359-
None => return Ok(Vec::new_in(a)),
2360+
None => return Ok(Self::new_in(a)),
23602361
Some(element) => {
23612362
let (lower, _) = iter.size_hint();
2362-
let mut vector = Vec::try_with_capacity_in(lower.saturating_add(1), a)?;
2363+
let mut vector = Self::try_with_capacity_in(lower.saturating_add(1), a)?;
23632364
unsafe {
23642365
ptr::write(vector.get_unchecked_mut(0), element);
23652366
vector.set_len(1);
@@ -2381,7 +2382,7 @@ where
23812382
I: TrustedLen<Item = T>,
23822383
{
23832384
default fn try_from_iter_in(iter: I, a: A) -> Result<Self, CollectionAllocErr<A>> {
2384-
let mut vector = Vec::new_in(a);
2385+
let mut vector = Self::new_in(a);
23852386
vector.try_spec_extend(iter)?;
23862387
Ok(vector)
23872388
}
@@ -2424,7 +2425,7 @@ impl<T, A: ReallocRef> SpecExtend<T, IntoIter<T, A>, A> for Vec<T, A> {
24242425
let ptr: *const T = iter.buf.ptr();
24252426
if ptr == iter.ptr {
24262427
unsafe {
2427-
let vec = Vec::from_raw_parts_in(
2428+
let vec = Self::from_raw_parts_in(
24282429
iter.buf.ptr(),
24292430
iter.len(),
24302431
iter.buf.capacity(),
@@ -2434,7 +2435,7 @@ impl<T, A: ReallocRef> SpecExtend<T, IntoIter<T, A>, A> for Vec<T, A> {
24342435
Ok(vec)
24352436
}
24362437
} else {
2437-
let mut vector = Vec::new_in(a);
2438+
let mut vector = Self::new_in(a);
24382439
vector.try_spec_extend(iter)?;
24392440
Ok(vector)
24402441
}

0 commit comments

Comments
 (0)