Skip to content

Commit

Permalink
get rid of strcow
Browse files Browse the repository at this point in the history
  • Loading branch information
asmello committed Feb 17, 2025
1 parent f96e4cc commit d191e24
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 109 deletions.
10 changes: 4 additions & 6 deletions src/pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ use alloc::{
};
use core::{borrow::Borrow, cmp::Ordering, iter::once, ops::Deref, str::FromStr};
use slice::PointerIndex;
use strcow::StrCow;

mod slice;
mod strcow;

/// A JSON Pointer is a string containing a sequence of zero or more reference
/// [`Token`]s, each prefixed by a `'/'` character.
Expand Down Expand Up @@ -370,7 +368,6 @@ impl Pointer {
/// [`ResolveError`]: `crate::resolve::ResolveError`
/// [`Token`]: `crate::Token`
/// [`Index`]: `crate::index::Index`
#[cfg(feature = "resolve")]
pub fn resolve_mut<'v, R: crate::ResolveMut>(
&self,
Expand Down Expand Up @@ -681,7 +678,7 @@ impl PartialEq<&str> for Pointer {
&&self.0 == other
}
}
impl<'p> PartialEq<String> for &'p Pointer {
impl PartialEq<String> for &Pointer {
fn eq(&self, other: &String) -> bool {
self.0.eq(other)
}
Expand Down Expand Up @@ -871,7 +868,7 @@ impl PartialOrd<&str> for PointerBuf {
}
}

impl<'p> PartialOrd<PointerBuf> for &'p Pointer {
impl PartialOrd<PointerBuf> for &Pointer {
fn partial_cmp(&self, other: &PointerBuf) -> Option<Ordering> {
self.0.partial_cmp(other.0.as_str())
}
Expand Down Expand Up @@ -925,7 +922,8 @@ impl PointerBuf {
///
/// ## Errors
/// Returns a [`RichParseError`] if the string is not a valid JSON Pointer.
pub fn parse(s: impl StrCow) -> Result<Self, ParseError> {
pub fn parse<'s>(s: impl Into<Cow<'s, str>>) -> Result<Self, ParseError> {
let s = s.into();
// must explicitly match due to borrow checker limitations
match validate(s.as_ref()) {
Ok(_) => Ok(Self(s.into_owned())),
Expand Down
103 changes: 0 additions & 103 deletions src/pointer/strcow.rs

This file was deleted.

0 comments on commit d191e24

Please sign in to comment.