mirror of
https://github.com/rust-embedded/heapless.git
synced 2025-10-02 06:50:32 +00:00
Fix clippy::use_self
warnings
This commit is contained in:
parent
3c97d2f035
commit
e3e07b796b
@ -596,14 +596,14 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T, K, S> PeekMutInner<'a, T, K, S>
|
||||
impl<T, K, S> PeekMutInner<'_, T, K, S>
|
||||
where
|
||||
T: Ord,
|
||||
K: Kind,
|
||||
S: VecStorage<T> + ?Sized,
|
||||
{
|
||||
/// Removes the peeked value from the heap and returns it.
|
||||
pub fn pop(mut this: PeekMutInner<'a, T, K, S>) -> T {
|
||||
pub fn pop(mut this: Self) -> T {
|
||||
let value = this.heap.pop().unwrap();
|
||||
this.sift = false;
|
||||
value
|
||||
|
@ -946,7 +946,7 @@ where
|
||||
T: Clone,
|
||||
{
|
||||
fn clone(&self) -> Self {
|
||||
let mut res = Deque::new();
|
||||
let mut res = Self::new();
|
||||
for i in self {
|
||||
// safety: the original and new deques have the same capacity, so it can
|
||||
// not become full.
|
||||
|
@ -97,7 +97,7 @@ pub struct Pos {
|
||||
|
||||
impl Pos {
|
||||
fn new(index: usize, hash: HashValue) -> Self {
|
||||
Pos {
|
||||
Self {
|
||||
nz: unsafe {
|
||||
NonZeroU32::new_unchecked(
|
||||
((u32::from(hash.0) << 16) + index as u32).wrapping_add(1),
|
||||
@ -146,7 +146,7 @@ impl<K, V, const N: usize> CoreMap<K, V, N> {
|
||||
const fn new() -> Self {
|
||||
const INIT: Option<Pos> = None;
|
||||
|
||||
CoreMap {
|
||||
Self {
|
||||
entries: Vec::new(),
|
||||
indices: [INIT; N],
|
||||
}
|
||||
@ -733,7 +733,7 @@ impl<K, V, S, const N: usize> IndexMap<K, V, BuildHasherDefault<S>, N> {
|
||||
crate::sealed::greater_than_1::<N>();
|
||||
crate::sealed::power_of_two::<N>();
|
||||
|
||||
IndexMap {
|
||||
Self {
|
||||
build_hasher: BuildHasherDefault::new(),
|
||||
core: CoreMap::new(),
|
||||
}
|
||||
@ -1240,7 +1240,7 @@ where
|
||||
crate::sealed::greater_than_1::<N>();
|
||||
crate::sealed::power_of_two::<N>();
|
||||
|
||||
IndexMap {
|
||||
Self {
|
||||
build_hasher: <_>::default(),
|
||||
core: CoreMap::new(),
|
||||
}
|
||||
@ -1309,7 +1309,7 @@ where
|
||||
where
|
||||
I: IntoIterator<Item = (K, V)>,
|
||||
{
|
||||
let mut map = IndexMap::default();
|
||||
let mut map = Self::default();
|
||||
map.extend(iterable);
|
||||
map
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ pub struct IndexSet<T, S, const N: usize> {
|
||||
impl<T, S, const N: usize> IndexSet<T, BuildHasherDefault<S>, N> {
|
||||
/// Creates an empty `IndexSet`
|
||||
pub const fn new() -> Self {
|
||||
IndexSet {
|
||||
Self {
|
||||
map: IndexMap::new(),
|
||||
}
|
||||
}
|
||||
@ -533,7 +533,7 @@ where
|
||||
S: Default,
|
||||
{
|
||||
fn default() -> Self {
|
||||
IndexSet {
|
||||
Self {
|
||||
map: <_>::default(),
|
||||
}
|
||||
}
|
||||
@ -586,7 +586,7 @@ where
|
||||
where
|
||||
I: IntoIterator<Item = T>,
|
||||
{
|
||||
let mut set = IndexSet::default();
|
||||
let mut set = Self::default();
|
||||
set.extend(iter);
|
||||
set
|
||||
}
|
||||
|
@ -140,6 +140,7 @@
|
||||
),
|
||||
feature(integer_atomics)
|
||||
)]
|
||||
#![warn(clippy::use_self)]
|
||||
|
||||
pub use binary_heap::BinaryHeap;
|
||||
pub use deque::Deque;
|
||||
|
@ -120,7 +120,7 @@ where
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_static_mut_ref(reference: &'static mut N) -> NonNullPtr<N> {
|
||||
pub fn from_static_mut_ref(reference: &'static mut N) -> Self {
|
||||
// SAFETY: `reference` is a static mutable reference, i.e. a valid pointer.
|
||||
unsafe { Self::new_unchecked(initial_tag(), NonNull::from(reference)) }
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ where
|
||||
T: Clone,
|
||||
{
|
||||
fn clone(&self) -> Self {
|
||||
let mut new: Queue<T, N> = Queue::new();
|
||||
let mut new: Self = Self::new();
|
||||
|
||||
for s in self.iter() {
|
||||
unsafe {
|
||||
@ -829,7 +829,7 @@ mod tests {
|
||||
unsafe {
|
||||
COUNT += 1;
|
||||
}
|
||||
Droppable
|
||||
Self
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -632,7 +632,7 @@ impl<const N: usize> Default for String<N> {
|
||||
impl<'a, const N: usize> TryFrom<&'a str> for String<N> {
|
||||
type Error = ();
|
||||
fn try_from(s: &'a str) -> Result<Self, Self::Error> {
|
||||
let mut new = String::new();
|
||||
let mut new = Self::new();
|
||||
new.push_str(s)?;
|
||||
Ok(new)
|
||||
}
|
||||
@ -642,7 +642,7 @@ impl<const N: usize> str::FromStr for String<N> {
|
||||
type Err = ();
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
let mut new = String::new();
|
||||
let mut new = Self::new();
|
||||
new.push_str(s)?;
|
||||
Ok(new)
|
||||
}
|
||||
@ -650,7 +650,7 @@ impl<const N: usize> str::FromStr for String<N> {
|
||||
|
||||
impl<const N: usize> iter::FromIterator<char> for String<N> {
|
||||
fn from_iter<T: IntoIterator<Item = char>>(iter: T) -> Self {
|
||||
let mut new = String::new();
|
||||
let mut new = Self::new();
|
||||
for c in iter {
|
||||
new.push(c).unwrap();
|
||||
}
|
||||
@ -660,7 +660,7 @@ impl<const N: usize> iter::FromIterator<char> for String<N> {
|
||||
|
||||
impl<'a, const N: usize> iter::FromIterator<&'a char> for String<N> {
|
||||
fn from_iter<T: IntoIterator<Item = &'a char>>(iter: T) -> Self {
|
||||
let mut new = String::new();
|
||||
let mut new = Self::new();
|
||||
for c in iter {
|
||||
new.push(*c).unwrap();
|
||||
}
|
||||
@ -670,7 +670,7 @@ impl<'a, const N: usize> iter::FromIterator<&'a char> for String<N> {
|
||||
|
||||
impl<'a, const N: usize> iter::FromIterator<&'a str> for String<N> {
|
||||
fn from_iter<T: IntoIterator<Item = &'a str>>(iter: T) -> Self {
|
||||
let mut new = String::new();
|
||||
let mut new = Self::new();
|
||||
for c in iter {
|
||||
new.push_str(c).unwrap();
|
||||
}
|
||||
@ -782,7 +782,7 @@ impl<S: VecStorage<u8> + ?Sized> PartialEq<&str> for StringInner<S> {
|
||||
impl<S: VecStorage<u8> + ?Sized> PartialEq<StringInner<S>> for str {
|
||||
#[inline]
|
||||
fn eq(&self, other: &StringInner<S>) -> bool {
|
||||
str::eq(self, &other[..])
|
||||
Self::eq(self, &other[..])
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -197,7 +197,7 @@ impl<T, const N: usize> Vec<T, N> {
|
||||
where
|
||||
T: Clone,
|
||||
{
|
||||
let mut v = Vec::new();
|
||||
let mut v = Self::new();
|
||||
v.extend_from_slice(other)?;
|
||||
Ok(v)
|
||||
}
|
||||
@ -229,7 +229,7 @@ impl<T, const N: usize> Vec<T, N> {
|
||||
buffer: unsafe { mem::transmute_copy(&src) },
|
||||
}
|
||||
} else {
|
||||
let mut v = Vec::<T, N>::new();
|
||||
let mut v = Self::new();
|
||||
|
||||
for (src_elem, dst_elem) in src.iter().zip(v.buffer.buffer.iter_mut()) {
|
||||
// NOTE(unsafe) src element is not going to drop as src itself
|
||||
@ -1222,7 +1222,7 @@ impl<'a, T: Clone, const N: usize> TryFrom<&'a [T]> for Vec<T, N> {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(slice: &'a [T]) -> Result<Self, Self::Error> {
|
||||
Vec::from_slice(slice)
|
||||
Self::from_slice(slice)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1279,7 +1279,7 @@ impl<T, const N: usize> FromIterator<T> for Vec<T, N> {
|
||||
where
|
||||
I: IntoIterator<Item = T>,
|
||||
{
|
||||
let mut vec = Vec::new();
|
||||
let mut vec = Self::new();
|
||||
for i in iter {
|
||||
vec.push(i).ok().expect("Vec::from_iter overflow");
|
||||
}
|
||||
@ -1509,14 +1509,14 @@ impl<T, S: VecStorage<T> + ?Sized> borrow::BorrowMut<[T]> for VecInner<T, S> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, S: VecStorage<T> + ?Sized> AsRef<VecInner<T, S>> for VecInner<T, S> {
|
||||
impl<T, S: VecStorage<T> + ?Sized> AsRef<Self> for VecInner<T, S> {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &Self {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, S: VecStorage<T> + ?Sized> AsMut<VecInner<T, S>> for VecInner<T, S> {
|
||||
impl<T, S: VecStorage<T> + ?Sized> AsMut<Self> for VecInner<T, S> {
|
||||
#[inline]
|
||||
fn as_mut(&mut self) -> &mut Self {
|
||||
self
|
||||
|
Loading…
x
Reference in New Issue
Block a user