fix: fmt crashing with comment at end of file

closes #568
This commit is contained in:
rvcas
2023-06-07 15:59:54 -04:00
parent feb2698e5e
commit 1747090931
2 changed files with 18 additions and 1 deletions

View File

@@ -24,7 +24,7 @@ pub struct Comment<'a> {
impl<'a> From<(&Span, &'a str)> for Comment<'a> {
fn from(src: (&Span, &'a str)) -> Comment<'a> {
fn char_indice(s: &str, i: usize) -> usize {
s.char_indices().nth(i).expect("char at given indice").0
s.char_indices().nth(i).unwrap_or((i, ' ')).0
}
let start = char_indice(src.1, src.0.start);