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