Skip to content

Commit

Permalink
Remove as_ref_loose
Browse files Browse the repository at this point in the history
It doesn't make sense.
  • Loading branch information
yescallop committed Oct 6, 2024
1 parent 269e405 commit 98ba13d
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/ri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,6 @@ macro_rules! ri_maybe_ref {
}
}

impl<T: Bos<str>> $Ty<T> {
fn as_ref_loose(&self) -> Ref<'_, '_> {
self.as_ref()
}
}

impl<'i, 'o, T: BorrowOrShare<'i, 'o, str>> $Ty<T> {
#[doc = concat!("Returns the ", $name, " as a string slice.")]
#[must_use]
Expand Down Expand Up @@ -392,7 +386,9 @@ macro_rules! ri_maybe_ref {
pub fn fragment(&'i self) -> Option<&'o EStr<$FragmentE>> {
self.as_ref().fragment().map(EStr::cast)
}
}

impl<'i, 'o, T: Bos<str>> $Ty<T> {
$(
#[doc = concat!("Resolves the ", $name, " against the given base ", $nr_name)]
#[doc = concat!("and returns the target ", $nr_name, ".")]
Expand Down Expand Up @@ -456,7 +452,7 @@ macro_rules! ri_maybe_ref {
&self,
base: &$NonRefTy<U>,
) -> Result<$NonRefTy<String>, ResolveError> {
resolver::resolve(base.as_ref(), self.as_ref_loose()).map(RiRef::from_pair)
resolver::resolve(base.as_ref(), self.as_ref()).map(RiRef::from_pair)
}
)?

Expand Down Expand Up @@ -495,7 +491,7 @@ macro_rules! ri_maybe_ref {
/// ```
#[must_use]
pub fn normalize(&self) -> $Ty<String> {
RiRef::from_pair(normalizer::normalize(self.as_ref_loose(), $must_be_ascii))
RiRef::from_pair(normalizer::normalize(self.as_ref(), $must_be_ascii))
}

cond!(if $must_have_scheme {} else {
Expand All @@ -512,7 +508,7 @@ macro_rules! ri_maybe_ref {
/// ```
#[must_use]
pub fn has_scheme(&self) -> bool {
self.as_ref_loose().has_scheme()
self.as_ref().has_scheme()
}
});

Expand All @@ -529,7 +525,7 @@ macro_rules! ri_maybe_ref {
/// ```
#[must_use]
pub fn has_authority(&self) -> bool {
self.as_ref_loose().has_authority()
self.as_ref().has_authority()
}

/// Checks whether a query component is present.
Expand All @@ -545,7 +541,7 @@ macro_rules! ri_maybe_ref {
/// ```
#[must_use]
pub fn has_query(&self) -> bool {
self.as_ref_loose().has_query()
self.as_ref().has_query()
}

/// Checks whether a fragment component is present.
Expand All @@ -561,7 +557,7 @@ macro_rules! ri_maybe_ref {
/// ```
#[must_use]
pub fn has_fragment(&self) -> bool {
self.as_ref_loose().has_fragment()
self.as_ref().has_fragment()
}
}

Expand Down Expand Up @@ -1022,7 +1018,7 @@ impl<T: Bos<str>> Iri<T> {
/// assert_eq!(iri.to_uri(), "http://r%C3%A9sum%C3%A9.example.org");
/// ```
pub fn to_uri(&self) -> Uri<String> {
RiRef::from_pair(encode_non_ascii(self.as_ref_loose()))
RiRef::from_pair(encode_non_ascii(self.as_ref()))
}
}

Expand All @@ -1043,7 +1039,7 @@ impl<T: Bos<str>> IriRef<T> {
/// assert_eq!(iri_ref.to_uri_ref(), "//r%C3%A9sum%C3%A9.example.org");
/// ```
pub fn to_uri_ref(&self) -> UriRef<String> {
RiRef::from_pair(encode_non_ascii(self.as_ref_loose()))
RiRef::from_pair(encode_non_ascii(self.as_ref()))
}
}

Expand Down

0 comments on commit 98ba13d

Please sign in to comment.