on master help sign in
Apply recent nightly suggestions (#1286)

array iterators are now implicit

commit02fc52f6d52c91c691dd2b7f9312b81aa20b8cbb authorKirawi <67773714+kirawi@users.noreply.github.com> dateSat 18 Dec 2021, 00:57 (5 years ago) parenta668335
3 files changed+27−29
helix-core/src/movement.rs+25−27 helix-term/src/commands.rs+1−1 helix-term/src/ui/prompt.rs+1−1
helix-core/src/movement.rs+25−27
@@ -307,8 +307,6 @@ fn reached_target(target: WordMotionTarget, prev_ch: char, next_ch: char) -> boo
307307
308308#[cfg(test)]
309309mod test {
310− use std::array::{self, IntoIter};
311−
312310 use ropey::Rope;
313311
314312 use super::*;
@@ -360,7 +358,7 @@ mod test {
360358 ((Direction::Backward, 999usize), (0, 0)), // |This is a simple alphabetic line
361359 ];
362360
363− for ((direction, amount), coordinates) in IntoIter::new(moves_and_expected_coordinates) {
361+ for ((direction, amount), coordinates) in moves_and_expected_coordinates {
364362 range = move_horizontally(slice, range, direction, amount, Movement::Move);
365363 assert_eq!(coords_at_pos(slice, range.head), coordinates.into())
366364 }
@@ -374,7 +372,7 @@ mod test {
374372
375373 let mut range = Range::point(position);
376374
377− let moves_and_expected_coordinates = IntoIter::new([
375+ let moves_and_expected_coordinates = [
378376 ((Direction::Forward, 11usize), (1, 1)), // Multiline\nt|ext sample\n...
379377 ((Direction::Backward, 1usize), (1, 0)), // Multiline\n|text sample\n...
380378 ((Direction::Backward, 5usize), (0, 5)), // Multi|line\ntext sample\n...
@@ -384,7 +382,7 @@ mod test {
384382 ((Direction::Backward, 0usize), (0, 3)), // Mul|tiline\ntext sample\n...
385383 ((Direction::Forward, 999usize), (5, 0)), // ...and whitespaced\n|
386384 ((Direction::Forward, 999usize), (5, 0)), // ...and whitespaced\n|
387− ]);
385+ ];
388386
389387 for ((direction, amount), coordinates) in moves_and_expected_coordinates {
390388 range = move_horizontally(slice, range, direction, amount, Movement::Move);
@@ -402,11 +400,11 @@ mod test {
402400 let mut range = Range::point(position);
403401 let original_anchor = range.anchor;
404402
405− let moves = IntoIter::new([
403+ let moves = [
406404 (Direction::Forward, 1usize),
407405 (Direction::Forward, 5usize),
408406 (Direction::Backward, 3usize),
409− ]);
407+ ];
410408
411409 for (direction, amount) in moves {
412410 range = move_horizontally(slice, range, direction, amount, Movement::Extend);
@@ -420,7 +418,7 @@ mod test {
420418 let slice = text.slice(..);
421419 let position = pos_at_coords(slice, (0, 0).into(), true);
422420 let mut range = Range::point(position);
423− let moves_and_expected_coordinates = IntoIter::new([
421+ let moves_and_expected_coordinates = [
424422 ((Direction::Forward, 1usize), (1, 0)),
425423 ((Direction::Forward, 2usize), (3, 0)),
426424 ((Direction::Forward, 1usize), (4, 0)),
@@ -430,7 +428,7 @@ mod test {
430428 ((Direction::Backward, 0usize), (4, 0)),
431429 ((Direction::Forward, 5), (5, 0)),
432430 ((Direction::Forward, 999usize), (5, 0)),
433− ]);
431+ ];
434432
435433 for ((direction, amount), coordinates) in moves_and_expected_coordinates {
436434 range = move_vertically(slice, range, direction, amount, Movement::Move);
@@ -450,7 +448,7 @@ mod test {
450448 H,
451449 V,
452450 }
453− let moves_and_expected_coordinates = IntoIter::new([
451+ let moves_and_expected_coordinates = [
454452 // Places cursor at the end of line
455453 ((Axis::H, Direction::Forward, 8usize), (0, 8)),
456454 // First descent preserves column as the target line is wider
@@ -463,7 +461,7 @@ mod test {
463461 ((Axis::V, Direction::Backward, 999usize), (0, 8)),
464462 ((Axis::V, Direction::Forward, 4usize), (4, 8)),
465463 ((Axis::V, Direction::Forward, 999usize), (5, 0)),
466− ]);
464+ ];
467465
468466 for ((axis, direction, amount), coordinates) in moves_and_expected_coordinates {
469467 range = match axis {
@@ -489,7 +487,7 @@ mod test {
489487 H,
490488 V,
491489 }
492− let moves_and_expected_coordinates = IntoIter::new([
490+ let moves_and_expected_coordinates = [
493491 // Places cursor at the fourth kana.
494492 ((Axis::H, Direction::Forward, 4), (0, 4)),
495493 // Descent places cursor at the 4th character.
@@ -498,7 +496,7 @@ mod test {
498496 ((Axis::H, Direction::Backward, 1usize), (1, 3)),
499497 // Jumping back up 1 line.
500498 ((Axis::V, Direction::Backward, 1usize), (0, 3)),
501− ]);
499+ ];
502500
503501 for ((axis, direction, amount), coordinates) in moves_and_expected_coordinates {
504502 range = match axis {
@@ -530,7 +528,7 @@ mod test {
530528
531529 #[test]
532530 fn test_behaviour_when_moving_to_start_of_next_words() {
533− let tests = array::IntoIter::new([
531+ let tests = [
534532 ("Basic forward motion stops at the first space",
535533 vec![(1, Range::new(0, 0), Range::new(0, 6))]),
536534 (" Starting from a boundary advances the anchor",
@@ -604,7 +602,7 @@ mod test {
604602 vec![
605603 (1, Range::new(0, 0), Range::new(0, 6)),
606604 ]),
607− ]);
605+ ];
608606
609607 for (sample, scenario) in tests {
610608 for (count, begin, expected_end) in scenario.into_iter() {
@@ -616,7 +614,7 @@ mod test {
616614
617615 #[test]
618616 fn test_behaviour_when_moving_to_start_of_next_long_words() {
619− let tests = array::IntoIter::new([
617+ let tests = [
620618 ("Basic forward motion stops at the first space",
621619 vec![(1, Range::new(0, 0), Range::new(0, 6))]),
622620 (" Starting from a boundary advances the anchor",
@@ -688,7 +686,7 @@ mod test {
688686 vec![
689687 (1, Range::new(0, 0), Range::new(0, 8)),
690688 ]),
691− ]);
689+ ];
692690
693691 for (sample, scenario) in tests {
694692 for (count, begin, expected_end) in scenario.into_iter() {
@@ -700,7 +698,7 @@ mod test {
700698
701699 #[test]
702700 fn test_behaviour_when_moving_to_start_of_previous_words() {
703− let tests = array::IntoIter::new([
701+ let tests = [
704702 ("Basic backward motion from the middle of a word",
705703 vec![(1, Range::new(3, 3), Range::new(4, 0))]),
706704
@@ -773,7 +771,7 @@ mod test {
773771 vec![
774772 (1, Range::new(0, 6), Range::new(6, 0)),
775773 ]),
776− ]);
774+ ];
777775
778776 for (sample, scenario) in tests {
779777 for (count, begin, expected_end) in scenario.into_iter() {
@@ -785,7 +783,7 @@ mod test {
785783
786784 #[test]
787785 fn test_behaviour_when_moving_to_start_of_previous_long_words() {
788− let tests = array::IntoIter::new([
786+ let tests = [
789787 (
790788 "Basic backward motion from the middle of a word",
791789 vec![(1, Range::new(3, 3), Range::new(4, 0))],
@@ -870,7 +868,7 @@ mod test {
870868 vec![
871869 (1, Range::new(0, 8), Range::new(8, 0)),
872870 ]),
873− ]);
871+ ];
874872
875873 for (sample, scenario) in tests {
876874 for (count, begin, expected_end) in scenario.into_iter() {
@@ -882,7 +880,7 @@ mod test {
882880
883881 #[test]
884882 fn test_behaviour_when_moving_to_end_of_next_words() {
885− let tests = array::IntoIter::new([
883+ let tests = [
886884 ("Basic forward motion from the start of a word to the end of it",
887885 vec![(1, Range::new(0, 0), Range::new(0, 5))]),
888886 ("Basic forward motion from the end of a word to the end of the next",
@@ -954,7 +952,7 @@ mod test {
954952 vec![
955953 (1, Range::new(0, 0), Range::new(0, 5)),
956954 ]),
957− ]);
955+ ];
958956
959957 for (sample, scenario) in tests {
960958 for (count, begin, expected_end) in scenario.into_iter() {
@@ -966,7 +964,7 @@ mod test {
966964
967965 #[test]
968966 fn test_behaviour_when_moving_to_end_of_previous_words() {
969− let tests = array::IntoIter::new([
967+ let tests = [
970968 ("Basic backward motion from the middle of a word",
971969 vec![(1, Range::new(9, 9), Range::new(10, 5))]),
972970 ("Starting from after boundary retreats the anchor",
@@ -1036,7 +1034,7 @@ mod test {
10361034 vec![
10371035 (1, Range::new(0, 10), Range::new(10, 4)),
10381036 ]),
1039− ]);
1037+ ];
10401038
10411039 for (sample, scenario) in tests {
10421040 for (count, begin, expected_end) in scenario.into_iter() {
@@ -1048,7 +1046,7 @@ mod test {
10481046
10491047 #[test]
10501048 fn test_behaviour_when_moving_to_end_of_next_long_words() {
1051− let tests = array::IntoIter::new([
1049+ let tests = [
10521050 ("Basic forward motion from the start of a word to the end of it",
10531051 vec![(1, Range::new(0, 0), Range::new(0, 5))]),
10541052 ("Basic forward motion from the end of a word to the end of the next",
@@ -1118,7 +1116,7 @@ mod test {
11181116 vec![
11191117 (1, Range::new(0, 0), Range::new(0, 7)),
11201118 ]),
1121− ]);
1119+ ];
11221120
11231121 for (sample, scenario) in tests {
11241122 for (count, begin, expected_end) in scenario.into_iter() {
helix-term/src/commands.rs+1−1
@@ -1938,7 +1938,7 @@ fn append_mode(cx: &mut Context) {
19381938 if !last_range.is_empty() && last_range.head == end {
19391939 let transaction = Transaction::change(
19401940 doc.text(),
1941− std::array::IntoIter::new([(end, end, Some(doc.line_ending.as_str().into()))]),
1941+ [(end, end, Some(doc.line_ending.as_str().into()))].into_iter(),
19421942 );
19431943 doc.apply(&transaction, view.id);
19441944 }
helix-term/src/ui/prompt.rs+1−1
@@ -127,7 +127,7 @@ impl Prompt {
127127 let mut char_position = char_indices
128128 .iter()
129129 .position(|(idx, _)| *idx == self.cursor)
130− .unwrap_or_else(|| char_indices.len());
130+ .unwrap_or(char_indices.len());
131131
132132 for _ in 0..rep {
133133 // Skip any non-whitespace characters