aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2017-05-09 10:25:05 -0500
committerGitHub <noreply@github.com>2017-05-09 10:25:05 -0500
commitf94dc8d69b22f330e6be19882f2f02e09895f18f (patch)
tree1ae1dc044221a582d14357df09e29bc0576ce4f0
parent58f51ef03b88e06745c4113e13ea2738e1af247d (diff)
parentcd733c7aff4468ff7a860dbc78ef20717e08b103 (diff)
downloadmilf-rs-f94dc8d69b22f330e6be19882f2f02e09895f18f.tar.gz
milf-rs-f94dc8d69b22f330e6be19882f2f02e09895f18f.zip
Merge pull request #170 from oli-obk/patch-1
Allow extracting the location of the error
-rw-r--r--src/de.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/de.rs b/src/de.rs
index 223d492..bd73649 100644
--- a/src/de.rs
+++ b/src/de.rs
@@ -1063,6 +1063,13 @@ impl<'a> Deserializer<'a> {
}
impl Error {
+ /// Produces a (line, column) pair of the position of the error if available
+ ///
+ /// All indexes are 0-based.
+ pub fn line_col(&self) -> Option<(usize, usize)> {
+ self.inner.line.map(|line| (line, self.inner.col))
+ }
+
fn from_kind(kind: ErrorKind) -> Error {
Error {
inner: Box::new(ErrorInner {