Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2f9230e

Browse files
committedJan 29, 2025·
Fix clippy::type_complexity in core
1 parent de34c7c commit 2f9230e

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed
 

‎src/map/core.rs

+11-22
Original file line numberDiff line numberDiff line change
@@ -102,23 +102,23 @@ fn update_index(table: &mut Indices, offset: usize, hash: HashValue, old: usize,
102102
*index = OffsetIndex::new(new, offset);
103103
}
104104

105+
/// A simple alias to help `clippy::type_complexity`
106+
type Pair<T> = (T, T);
107+
105108
#[inline]
106-
fn len_slices<T>((head, tail): (&[T], &[T])) -> usize {
109+
fn len_slices<T>((head, tail): Pair<&[T]>) -> usize {
107110
head.len() + tail.len()
108111
}
109112

110113
#[inline]
111-
fn iter_slices<'a, T>(
112-
(head, tail): (&'a [T], &'a [T]),
113-
) -> iter::Chain<slice::Iter<'a, T>, slice::Iter<'a, T>> {
114+
fn iter_slices<T>(
115+
(head, tail): Pair<&'_ [T]>,
116+
) -> iter::Chain<slice::Iter<'_, T>, slice::Iter<'_, T>> {
114117
head.iter().chain(tail)
115118
}
116119

117120
#[inline]
118-
fn split_slices<'a, T>(
119-
(head, tail): (&'a [T], &'a [T]),
120-
i: usize,
121-
) -> ((&'a [T], &'a [T]), (&'a [T], &'a [T])) {
121+
fn split_slices<T>((head, tail): Pair<&'_ [T]>, i: usize) -> Pair<Pair<&'_ [T]>> {
122122
if i <= head.len() {
123123
let (head, mid) = head.split_at(i);
124124
((head, &[]), (mid, tail))
@@ -129,10 +129,7 @@ fn split_slices<'a, T>(
129129
}
130130

131131
#[inline]
132-
fn split_slices_mut<'a, T>(
133-
(head, tail): (&'a mut [T], &'a mut [T]),
134-
i: usize,
135-
) -> ((&'a mut [T], &'a mut [T]), (&'a mut [T], &'a mut [T])) {
132+
fn split_slices_mut<T>((head, tail): Pair<&'_ mut [T]>, i: usize) -> Pair<Pair<&'_ mut [T]>> {
136133
if i <= head.len() {
137134
let (head, mid) = head.split_at_mut(i);
138135
((head, &mut []), (mid, tail))
@@ -143,11 +140,7 @@ fn split_slices_mut<'a, T>(
143140
}
144141

145142
#[inline]
146-
fn sub_slices_mut<'a, T>(
147-
slices: (&'a mut [T], &'a mut [T]),
148-
start: usize,
149-
end: usize,
150-
) -> (&'a mut [T], &'a mut [T]) {
143+
fn sub_slices_mut<T>(slices: Pair<&'_ mut [T]>, start: usize, end: usize) -> Pair<&'_ mut [T]> {
151144
let (slices, _) = split_slices_mut(slices, end);
152145
split_slices_mut(slices, start).1
153146
}
@@ -156,11 +149,7 @@ fn sub_slices_mut<'a, T>(
156149
/// and without regard for duplication.
157150
///
158151
/// ***Panics*** if there is not sufficient capacity already.
159-
fn insert_bulk_no_grow<K, V>(
160-
indices: &mut Indices,
161-
offset: usize,
162-
entries: (&[Bucket<K, V>], &[Bucket<K, V>]),
163-
) {
152+
fn insert_bulk_no_grow<K, V>(indices: &mut Indices, offset: usize, entries: Pair<&[Bucket<K, V>]>) {
164153
assert!(indices.capacity() - indices.len() >= len_slices(entries));
165154
for entry in iter_slices(entries) {
166155
let index = OffsetIndex::new(indices.len(), offset);

0 commit comments

Comments
 (0)
Please sign in to comment.