diff --git a/crates/editor/src/input.rs b/crates/editor/src/input.rs index 876bb8fa28..8192fc4a18 100644 --- a/crates/editor/src/input.rs +++ b/crates/editor/src/input.rs @@ -1666,10 +1666,8 @@ impl Editor { this.change_selections(Default::default(), window, cx, |s| s.select(selections)); let selections = this.selections.all::(&this.display_snapshot(cx)); - let selections_on_single_row = selections.windows(2).all(|selections| { - selections[0].start.row == selections[1].start.row - && selections[0].end.row == selections[1].end.row - && selections[0].start.row == selections[0].end.row + let selections_on_single_row = selections.array_windows::<2>().all(|[a, b]| { + a.start.row == b.start.row && a.end.row == b.end.row && a.start.row == a.end.row }); let selections_selecting = selections .iter() diff --git a/crates/file_finder/src/file_finder.rs b/crates/file_finder/src/file_finder.rs index f3711361d1..1203e3dde0 100644 --- a/crates/file_finder/src/file_finder.rs +++ b/crates/file_finder/src/file_finder.rs @@ -1952,7 +1952,7 @@ impl<'a> PathComponentSlice<'a> { fn elision_range(&self, budget: usize, matches: &[usize]) -> Option> { let eligible_range = { - assert!(matches.windows(2).all(|w| w[0] <= w[1])); + assert!(matches.is_sorted()); let mut matches = matches.iter().copied().peekable(); let mut longest: Option> = None; let mut cur = 0..0; diff --git a/crates/markdown/src/html/html_rendering.rs b/crates/markdown/src/html/html_rendering.rs index 25e869625f..00b73f1e44 100644 --- a/crates/markdown/src/html/html_rendering.rs +++ b/crates/markdown/src/html/html_rendering.rs @@ -391,9 +391,7 @@ impl MarkdownElement { boundaries.sort_unstable(); boundaries.dedup(); - for segment in boundaries.windows(2) { - let start = segment[0]; - let end = segment[1]; + for &[start, end] in boundaries.array_windows::<2>() { if start >= end { continue; } diff --git a/crates/outline_panel/src/outline_panel.rs b/crates/outline_panel/src/outline_panel.rs index 7c3845eb98..c880891502 100644 --- a/crates/outline_panel/src/outline_panel.rs +++ b/crates/outline_panel/src/outline_panel.rs @@ -3447,10 +3447,8 @@ impl OutlinePanel { }; let fetched_outlines = outline_task.await; let outlines_with_children = fetched_outlines - .windows(2) - .filter_map(|window| { - let current = &window[0]; - let next = &window[1]; + .array_windows::<2>() + .filter_map(|[current, next]| { if next.depth > current.depth { Some((current.range.clone(), current.depth)) } else { diff --git a/crates/zeta_prompt/src/multi_region.rs b/crates/zeta_prompt/src/multi_region.rs index 540bc2db11..0cecb38dec 100644 --- a/crates/zeta_prompt/src/multi_region.rs +++ b/crates/zeta_prompt/src/multi_region.rs @@ -582,8 +582,8 @@ pub fn nearest_marker_number(cursor_offset: Option, marker_offsets: &[usi fn cursor_block_index(cursor_offset: Option, marker_offsets: &[usize]) -> usize { let cursor = cursor_offset.unwrap_or(0); marker_offsets - .windows(2) - .position(|window| cursor >= window[0] && cursor < window[1]) + .array_windows::<2>() + .position(|&[a, b]| cursor >= a && cursor < b) .unwrap_or_else(|| marker_offsets.len().saturating_sub(2)) } @@ -1220,10 +1220,7 @@ hhhhhhhhhh = 8; Some(text.len()), "offsets: {offsets:?}" ); - assert!( - offsets.windows(2).all(|window| window[0] <= window[1]), - "offsets must be sorted: {offsets:?}" - ); + assert!(offsets.is_sorted(), "offsets must be sorted: {offsets:?}"); } #[test]