From e57523d46663bdd1989993b7ce864d2f40e007e3 Mon Sep 17 00:00:00 2001 From: Chance Date: Thu, 26 Sep 2024 13:48:08 -0400 Subject: [PATCH] minor refactoring of generics --- src/pointer.rs | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/src/pointer.rs b/src/pointer.rs index e42a216..21cd063 100644 --- a/src/pointer.rs +++ b/src/pointer.rs @@ -437,12 +437,9 @@ impl Pointer { /// let foobar = ptr.with_trailing_token("bar"); /// assert_eq!(foobar, "/foo/bar"); /// ``` - pub fn with_trailing_token<'t, T>(&self, token: T) -> PointerBuf - where - T: Into>, - { + pub fn with_trailing_token<'t>(&self, token: impl Into>) -> PointerBuf { let mut buf = self.to_buf(); - buf.push_back(token); + buf.push_back(token.into()); buf } @@ -460,10 +457,7 @@ impl Pointer { /// let foobar = ptr.with_leading_token("foo"); /// assert_eq!(foobar, "/foo/bar"); /// ``` - pub fn with_leading_token<'t, T>(&self, token: T) -> PointerBuf - where - T: Into>, - { + pub fn with_leading_token<'t>(&self, token: impl Into>) -> PointerBuf { let mut buf = self.to_buf(); buf.push_front(token); buf @@ -807,19 +801,13 @@ impl PointerBuf { } /// Pushes a `Token` onto the front of this `Pointer`. - pub fn push_front<'t, T>(&mut self, token: T) - where - T: Into>, - { + pub fn push_front<'t>(&mut self, token: impl Into>) { self.0.insert(0, '/'); self.0.insert_str(1, token.into().encoded()); } /// Pushes a `Token` onto the back of this `Pointer`. - pub fn push_back<'t, T>(&mut self, token: T) - where - T: Into>, - { + pub fn push_back<'t>(&mut self, token: impl Into>) { self.0.push('/'); self.0.push_str(token.into().encoded()); } @@ -866,10 +854,11 @@ impl PointerBuf { /// /// ## Errors /// A [`ReplaceError`] is returned if the index is out of bounds. - pub fn replace<'t, T>(&mut self, index: usize, token: T) -> Result, ReplaceError> - where - T: Into>, - { + pub fn replace<'t>( + &mut self, + index: usize, + token: impl Into>, + ) -> Result, ReplaceError> { if self.is_root() { return Err(ReplaceError { count: self.count(),