Skip to content

Commit

Permalink
Merge pull request #81 from Wicpar/main
Browse files Browse the repository at this point in the history
fix: unsealed PathComponentKind to allow custom key types in garde.
  • Loading branch information
jprochazk committed Dec 29, 2023
2 parents c56edc4 + de1dfe8 commit f5e95a3
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions garde/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,12 @@ impl std::fmt::Display for NoKey {
}
}

pub trait PathComponentKind: std::fmt::Display + ToCompactString + private::Sealed {
pub trait PathComponentKind: std::fmt::Display + ToCompactString {
fn component_kind() -> Kind;
}

macro_rules! impl_path_component_kind {
($(@$($G:lifetime)*;)? $T:ty => $which:ident) => {
impl $(<$($G),*>)? private::Sealed for $T {}
impl $(<$($G),*>)? PathComponentKind for $T {
fn component_kind() -> Kind {
Kind::$which
Expand All @@ -132,17 +131,12 @@ impl_path_component_kind!(String => Key);
impl_path_component_kind!(CompactString => Key);
impl_path_component_kind!(NoKey => None);

impl<'a, T: PathComponentKind> private::Sealed for &'a T {}
impl<'a, T: PathComponentKind> PathComponentKind for &'a T {
fn component_kind() -> Kind {
T::component_kind()
}
}

mod private {
pub trait Sealed {}
}

impl Path {
pub fn empty() -> Self {
Self {
Expand Down

0 comments on commit f5e95a3

Please sign in to comment.