aboutsummaryrefslogtreecommitdiff
path: root/bin/src/fix/single.rs
diff options
context:
space:
mode:
Diffstat (limited to 'bin/src/fix/single.rs')
-rw-r--r--bin/src/fix/single.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/bin/src/fix/single.rs b/bin/src/fix/single.rs
index 24b5c51..c09c710 100644
--- a/bin/src/fix/single.rs
+++ b/bin/src/fix/single.rs
@@ -12,7 +12,11 @@ pub struct SingleFixResult<'δ> {
12 12
13fn pos_to_byte(line: usize, col: usize, src: &str) -> Result<TextSize, SingleFixErr> { 13fn pos_to_byte(line: usize, col: usize, src: &str) -> Result<TextSize, SingleFixErr> {
14 let mut byte: TextSize = TextSize::of(""); 14 let mut byte: TextSize = TextSize::of("");
15 for (l, _) in src.split_inclusive('\n').zip(1..).take_while(|(_, i)| i < &line) { 15 for (l, _) in src
16 .split_inclusive('\n')
17 .zip(1..)
18 .take_while(|(_, i)| i < &line)
19 {
16 byte += TextSize::of(l); 20 byte += TextSize::of(l);
17 } 21 }
18 byte += TextSize::try_from(col).map_err(|_| SingleFixErr::Conversion(col))?; 22 byte += TextSize::try_from(col).map_err(|_| SingleFixErr::Conversion(col))?;
@@ -45,8 +49,8 @@ fn find(offset: TextSize, src: &str) -> Result<Report, SingleFixErr> {
45 } else { 49 } else {
46 None 50 None
47 } 51 }
48 }, 52 }
49 _ => None 53 _ => None,
50 }) 54 })
51 .flatten() 55 .flatten()
52 .next() 56 .next()
@@ -60,7 +64,5 @@ pub fn single(line: usize, col: usize, src: &str) -> Result<SingleFixResult, Sin
60 64
61 report.apply(src.to_mut()); 65 report.apply(src.to_mut());
62 66
63 Ok(SingleFixResult { 67 Ok(SingleFixResult { src })
64 src
65 })
66} 68}