mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 10:49:50 +00:00
Add unreachable code rule (#5384)
Co-authored-by: Thomas de Zeeuw <thomas@astral.sh> Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
parent
937de121f3
commit
0b963ddcfa
30 changed files with 4688 additions and 4 deletions
|
@ -40,6 +40,11 @@ impl<I: Idx, T> IndexSlice<I, T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub const fn first(&self) -> Option<&T> {
|
||||
self.raw.first()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub const fn len(&self) -> usize {
|
||||
self.raw.len()
|
||||
|
@ -63,6 +68,13 @@ impl<I: Idx, T> IndexSlice<I, T> {
|
|||
(0..self.len()).map(|n| I::new(n))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn iter_enumerated(
|
||||
&self,
|
||||
) -> impl DoubleEndedIterator<Item = (I, &T)> + ExactSizeIterator + '_ {
|
||||
self.raw.iter().enumerate().map(|(n, t)| (I::new(n), t))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn iter_mut(&mut self) -> std::slice::IterMut<'_, T> {
|
||||
self.raw.iter_mut()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue