From 0a180705534e3ad389c2c49025fe657dba12c0a5 Mon Sep 17 00:00:00 2001 From: Chance Date: Wed, 10 Jul 2024 17:44:50 -0400 Subject: [PATCH] removes offset method from `InvalidEncodingERror` (#63) * removes offset method from `InvalidEncodingERror` --- src/token.rs | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/token.rs b/src/token.rs index 9772ea6..82305dd 100644 --- a/src/token.rs +++ b/src/token.rs @@ -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 @@ -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!( @@ -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();