Skip to content

Commit

Permalink
removes offset method from InvalidEncodingERror (#63)
Browse files Browse the repository at this point in the history
* removes offset method from `InvalidEncodingERror`
  • Loading branch information
chanced authored Jul 10, 2024
1 parent bf73713 commit 0a18070
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl<'a> Token<'a> {
/// # use jsonptr::Token;
/// assert_eq!(Token::from_encoded("~1foo~1~0bar").unwrap().decoded(), "/foo/~bar");
/// let err = Token::from_encoded("foo/oops~bar").unwrap_err();
/// assert_eq!(err.offset(), 3);
/// assert_eq!(err.offset, 3);
/// ```
///
/// ## Errors
Expand Down Expand Up @@ -340,13 +340,6 @@ pub struct InvalidEncodingError {
pub offset: usize,
}

impl InvalidEncodingError {
/// The byte offset of the first invalid `~`.
pub fn offset(&self) -> usize {
self.offset
}
}

impl fmt::Display for InvalidEncodingError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
Expand Down Expand Up @@ -462,12 +455,6 @@ mod tests {
assert!(Token::from_encoded("a~a").is_err());
}

#[test]
fn invalid_encoding_offset() {
let err = InvalidEncodingError { offset: 3 };
assert_eq!(err.offset(), 3);
}

#[test]
fn into_owned() {
let token = Token::from_encoded("foo~0").unwrap().into_owned();
Expand Down

0 comments on commit 0a18070

Please sign in to comment.