@@ -101,7 +101,7 @@ impl State {
101101 let line = text.char_to_line(pos);
102102 let start = text.line_to_char(line);
103103 let pos = std::cmp::max(
104− nth_prev_grapheme_boundary(&text.slice(..), pos, count),
104+ nth_prev_grapheme_boundary(text.slice(..), pos, count),
105105 start,
106106 );
107107 Range::new(if extend { range.anchor } else { pos }, pos)
@@ -113,14 +113,14 @@ impl State {
113113 // subtract another 1 because the line ends with \n
114114 let end = text.line_to_char(line + 1).saturating_sub(2);
115115 let pos =
116− std::cmp::min(nth_next_grapheme_boundary(&text.slice(..), pos, count), end);
116+ std::cmp::min(nth_next_grapheme_boundary(text.slice(..), pos, count), end);
117117 Range::new(if extend { range.anchor } else { pos }, pos)
118118 }
119− (_, Granularity::Line) => move_vertically(&text.slice(..), dir, range, count, extend),
119+ (_, Granularity::Line) => move_vertically(text.slice(..), dir, range, count, extend),
120120 }
121121 }
122122
123− pub fn move_next_word_start(slice: &RopeSlice, mut pos: usize) -> usize {
123+ pub fn move_next_word_start(slice: RopeSlice, mut pos: usize) -> usize {
124124 // TODO: confirm it's fine without using graphemes, I think it should be
125125 let ch = slice.char(pos);
126126 let next = slice.char(pos.saturating_add(1));
@@ -143,7 +143,7 @@ impl State {
143143 pos
144144 }
145145
146− pub fn move_prev_word_start(slice: &RopeSlice, mut pos: usize) -> usize {
146+ pub fn move_prev_word_start(slice: RopeSlice, mut pos: usize) -> usize {
147147 // TODO: confirm it's fine without using graphemes, I think it should be
148148 let ch = slice.char(pos);
149149 let prev = slice.char(pos.saturating_sub(1)); // TODO: just return original pos if at start
@@ -169,7 +169,7 @@ impl State {
169169 pos.saturating_add(1)
170170 }
171171
172− pub fn move_next_word_end(slice: &RopeSlice, mut pos: usize, _count: usize) -> usize {
172+ pub fn move_next_word_end(slice: RopeSlice, mut pos: usize, _count: usize) -> usize {
173173 // TODO: confirm it's fine without using graphemes, I think it should be
174174 let ch = slice.char(pos);
175175 let next = slice.char(pos.saturating_add(1));
@@ -217,7 +217,7 @@ impl State {
217217}
218218
219219/// Convert a character index to (line, column) coordinates.
220−pub fn coords_at_pos(text: &RopeSlice, pos: usize) -> Position {
220+pub fn coords_at_pos(text: RopeSlice, pos: usize) -> Position {
221221 let line = text.char_to_line(pos);
222222 let line_start = text.line_to_char(line);
223223 let col = text.slice(line_start..pos).len_chars();
@@ -225,14 +225,14 @@ pub fn coords_at_pos(text: &RopeSlice, pos: usize) -> Position {
225225}
226226
227227/// Convert (line, column) coordinates to a character index.
228−pub fn pos_at_coords(text: &RopeSlice, coords: Position) -> usize {
228+pub fn pos_at_coords(text: RopeSlice, coords: Position) -> usize {
229229 let Position { row, col } = coords;
230230 let line_start = text.line_to_char(row);
231231 nth_next_grapheme_boundary(text, line_start, col)
232232}
233233
234234fn move_vertically(
235− text: &RopeSlice,
235+ text: RopeSlice,
236236 dir: Direction,
237237 range: Range,
238238 count: usize,
@@ -287,7 +287,7 @@ fn categorize(ch: char) -> Category {
287287 }
288288}
289289
290−fn skip_over_next<F>(slice: &RopeSlice, pos: &mut usize, fun: F)
290+fn skip_over_next<F>(slice: RopeSlice, pos: &mut usize, fun: F)
291291where
292292 F: Fn(char) -> bool,
293293{
@@ -301,7 +301,7 @@ where
301301 }
302302}
303303
304−fn skip_over_prev<F>(slice: &RopeSlice, pos: &mut usize, fun: F)
304+fn skip_over_prev<F>(slice: RopeSlice, pos: &mut usize, fun: F)
305305where
306306 F: Fn(char) -> bool,
307307{
@@ -323,34 +323,36 @@ mod test {
323323 #[test]
324324 fn test_coords_at_pos() {
325325 let text = Rope::from("ḧëḷḷö\nẅöṛḷḋ");
326− assert_eq!(coords_at_pos(&text.slice(..), 0), (0, 0).into());
327− assert_eq!(coords_at_pos(&text.slice(..), 5), (0, 5).into()); // position on \n
328− assert_eq!(coords_at_pos(&text.slice(..), 6), (1, 0).into()); // position on w
329− assert_eq!(coords_at_pos(&text.slice(..), 7), (1, 1).into()); // position on o
330− assert_eq!(coords_at_pos(&text.slice(..), 10), (1, 4).into()); // position on d
326+ let slice = text.slice(..);
327+ assert_eq!(coords_at_pos(slice, 0), (0, 0).into());
328+ assert_eq!(coords_at_pos(slice, 5), (0, 5).into()); // position on \n
329+ assert_eq!(coords_at_pos(slice, 6), (1, 0).into()); // position on w
330+ assert_eq!(coords_at_pos(slice, 7), (1, 1).into()); // position on o
331+ assert_eq!(coords_at_pos(slice, 10), (1, 4).into()); // position on d
331332 }
332333
333334 #[test]
334335 fn test_pos_at_coords() {
335336 let text = Rope::from("ḧëḷḷö\nẅöṛḷḋ");
336− assert_eq!(pos_at_coords(&text.slice(..), (0, 0).into()), 0);
337− assert_eq!(pos_at_coords(&text.slice(..), (0, 5).into()), 5); // position on \n
338− assert_eq!(pos_at_coords(&text.slice(..), (1, 0).into()), 6); // position on w
339− assert_eq!(pos_at_coords(&text.slice(..), (1, 1).into()), 7); // position on o
340− assert_eq!(pos_at_coords(&text.slice(..), (1, 4).into()), 10); // position on d
337+ let slice = text.slice(..);
338+ assert_eq!(pos_at_coords(slice, (0, 0).into()), 0);
339+ assert_eq!(pos_at_coords(slice, (0, 5).into()), 5); // position on \n
340+ assert_eq!(pos_at_coords(slice, (1, 0).into()), 6); // position on w
341+ assert_eq!(pos_at_coords(slice, (1, 1).into()), 7); // position on o
342+ assert_eq!(pos_at_coords(slice, (1, 4).into()), 10); // position on d
341343 }
342344
343345 #[test]
344346 fn test_vertical_move() {
345347 let text = Rope::from("abcd\nefg\nwrs");
346− let pos = pos_at_coords(&text.slice(..), (0, 4).into());
347348 let slice = text.slice(..);
349+ let pos = pos_at_coords(slice, (0, 4).into());
348350
349351 let range = Range::new(pos, pos);
350352 assert_eq!(
351353 coords_at_pos(
352− &slice,
353− move_vertically(&slice, Direction::Forward, range, 1, false).head
354+ slice,
355+ move_vertically(slice, Direction::Forward, range, 1, false).head
354356 ),
355357 (1, 2).into()
356358 );