Skip to content

Commit 415be56

Browse files
committed
Avoid redundant deref/ref in match blocks
1 parent 5b902f7 commit 415be56

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

src/seq/index.rs

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,20 @@ impl IndexVec {
4343
/// Returns the number of indices
4444
#[inline]
4545
pub fn len(&self) -> usize {
46-
match *self {
47-
IndexVec::U32(ref v) => v.len(),
46+
match self {
47+
IndexVec::U32(v) => v.len(),
4848
#[cfg(target_pointer_width = "64")]
49-
IndexVec::U64(ref v) => v.len(),
49+
IndexVec::U64(v) => v.len(),
5050
}
5151
}
5252

5353
/// Returns `true` if the length is 0.
5454
#[inline]
5555
pub fn is_empty(&self) -> bool {
56-
match *self {
57-
IndexVec::U32(ref v) => v.is_empty(),
56+
match self {
57+
IndexVec::U32(v) => v.is_empty(),
5858
#[cfg(target_pointer_width = "64")]
59-
IndexVec::U64(ref v) => v.is_empty(),
59+
IndexVec::U64(v) => v.is_empty(),
6060
}
6161
}
6262

@@ -66,10 +66,10 @@ impl IndexVec {
6666
/// restrictions.)
6767
#[inline]
6868
pub fn index(&self, index: usize) -> usize {
69-
match *self {
70-
IndexVec::U32(ref v) => v[index] as usize,
69+
match self {
70+
IndexVec::U32(v) => v[index] as usize,
7171
#[cfg(target_pointer_width = "64")]
72-
IndexVec::U64(ref v) => v[index] as usize,
72+
IndexVec::U64(v) => v[index] as usize,
7373
}
7474
}
7575

@@ -86,10 +86,10 @@ impl IndexVec {
8686
/// Iterate over the indices as a sequence of `usize` values
8787
#[inline]
8888
pub fn iter(&self) -> IndexVecIter<'_> {
89-
match *self {
90-
IndexVec::U32(ref v) => IndexVecIter::U32(v.iter()),
89+
match self {
90+
IndexVec::U32(v) => IndexVecIter::U32(v.iter()),
9191
#[cfg(target_pointer_width = "64")]
92-
IndexVec::U64(ref v) => IndexVecIter::U64(v.iter()),
92+
IndexVec::U64(v) => IndexVecIter::U64(v.iter()),
9393
}
9494
}
9595
}
@@ -158,17 +158,17 @@ impl<'a> Iterator for IndexVecIter<'a> {
158158
#[inline]
159159
fn next(&mut self) -> Option<usize> {
160160
use self::IndexVecIter::*;
161-
match *self {
162-
U32(ref mut iter) => iter.next().map(|i| *i as usize),
163-
U64(ref mut iter) => iter.next().map(|i| *i as usize),
161+
match self {
162+
U32(iter) => iter.next().map(|i| *i as usize),
163+
U64(iter) => iter.next().map(|i| *i as usize),
164164
}
165165
}
166166

167167
#[inline]
168168
fn size_hint(&self) -> (usize, Option<usize>) {
169-
match *self {
170-
IndexVecIter::U32(ref v) => v.size_hint(),
171-
IndexVecIter::U64(ref v) => v.size_hint(),
169+
match self {
170+
IndexVecIter::U32(v) => v.size_hint(),
171+
IndexVecIter::U64(v) => v.size_hint(),
172172
}
173173
}
174174
}
@@ -190,18 +190,18 @@ impl Iterator for IndexVecIntoIter {
190190
#[inline]
191191
fn next(&mut self) -> Option<Self::Item> {
192192
use self::IndexVecIntoIter::*;
193-
match *self {
194-
U32(ref mut v) => v.next().map(|i| i as usize),
195-
U64(ref mut v) => v.next().map(|i| i as usize),
193+
match self {
194+
U32(v) => v.next().map(|i| i as usize),
195+
U64(v) => v.next().map(|i| i as usize),
196196
}
197197
}
198198

199199
#[inline]
200200
fn size_hint(&self) -> (usize, Option<usize>) {
201201
use self::IndexVecIntoIter::*;
202-
match *self {
203-
U32(ref v) => v.size_hint(),
204-
U64(ref v) => v.size_hint(),
202+
match self {
203+
U32(v) => v.size_hint(),
204+
U64(v) => v.size_hint(),
205205
}
206206
}
207207
}
@@ -627,6 +627,7 @@ mod test {
627627
assert!((i as usize) < len);
628628
}
629629
}
630+
#[cfg(target_pointer_width = "64")]
630631
_ => panic!("expected `IndexVec::U32`"),
631632
}
632633
}

0 commit comments

Comments
 (0)