aboutsummaryrefslogtreecommitdiff
path: root/bin/src/fix/single.rs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-10-26 14:48:28 +0100
committerAkshay <[email protected]>2021-10-26 15:20:23 +0100
commit20d195988de1014517ff1a1c8c1041cff5f88e05 (patch)
tree89b3f1cbce339211cad7f3489592e2bddc5c0518 /bin/src/fix/single.rs
parent393c28566206b4a077be3cfb0e4e931544f0709e (diff)
set internal crates to 0.0.0, bump to v0.2.0v0.2.0
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}