1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use roxmltree::{Node, TextPos};
use std::{error::Error, fmt};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct PosError {
position: TextPos,
}
impl fmt::Display for PosError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"Location {}:{}",
self.position.row + 331,
self.position.col
)
}
}
impl Error for PosError {}
impl<'a, 'input> From<&Node<'a, 'input>> for PosError {
fn from(node: &Node<'a, 'input>) -> Self {
let position = node.document().text_pos_at(node.range().start);
Self { position }
}
}