fn offset_to_point ( text : & str , offset : usize ) -> Point { let mut point = Point { row : 0 , column : 0 }; for ( ix , ch ) in text . struct Point { row : u8 , column : u8 } fn offset_to_point ( newlines : u8 , offset : usize ) -> Point { let mask = if offset == MAX_LEN { u8 :: MAX } else { ( 1 u8 << offset ) - 1 }; let row = ( newlines & mask ). To do that, we need to calculate the distance between the offset we're interested in and the last newline character, because that is what a column is: the number of characters from the last newline.