Skip to content

Commit

Permalink
deref + fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
asmello committed Nov 18, 2024
1 parent 8b63c7a commit a9cfea1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2116,7 +2116,7 @@ mod tests {
assert!(invalid.is_err());
assert_eq!(
invalid.unwrap_err().to_string(),
"failed to parse json pointer\n\ncaused by:\njson pointer is malformed as it does not start with a backslash ('/') at line 1 column 9"
"failed to parse json pointer\n\ncaused by:\njson pointer is malformed as it does not start with a backslash ('/') and is not empty at line 1 column 9"
);
}

Expand Down
13 changes: 12 additions & 1 deletion src/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl<'s, S: Enrich<'s>> Enriched<'s, S> {
}

/// The error which occurred.
pub fn source(&self) -> &S {
pub fn original(&self) -> &S {
&self.source
}

Expand All @@ -79,6 +79,17 @@ impl<'s, S: Enrich<'s>> Enriched<'s, S> {
}
}

impl<'s, S> core::ops::Deref for Enriched<'s, S>
where
S: Enrich<'s>,
{
type Target = S;

fn deref(&self) -> &Self::Target {
&self.source
}
}

impl<'s, S> fmt::Display for Enriched<'s, S>
where
S: Enrich<'s> + fmt::Display,
Expand Down
2 changes: 1 addition & 1 deletion src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ mod tests {
fn invalid_encoding_error_display() {
assert_eq!(
Token::from_encoded("~").unwrap_err().to_string(),
"json pointer is malformed due to invalid encoding ('~' not followed by '0' or '1')"
"json pointer is malformed due to invalid encoding"
);
}

Expand Down

0 comments on commit a9cfea1

Please sign in to comment.