Diffstat (limited to 'src/protocol/visitor.rs')
| -rw-r--r-- | src/protocol/visitor.rs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/protocol/visitor.rs b/src/protocol/visitor.rs index ecb48d1..fbcfdd2 100644 --- a/src/protocol/visitor.rs +++ b/src/protocol/visitor.rs @@ -12,7 +12,8 @@ pub use sequence::*; pub use tag::*; pub use value::*; -#[derive(Debug, Copy, Clone, PartialEq)] +#[derive(Copy, Clone)] +#[must_use] pub enum VisitResult<S> { /// The protocol was not used. /// @@ -24,6 +25,25 @@ pub enum VisitResult<S> { Control(Flow), } +impl<S> PartialEq for VisitResult<S> { + fn eq(&self, other: &Self) -> bool { + match (self, other) { + (Self::Skipped(_), Self::Skipped(_)) => true, + (Self::Control(l0), Self::Control(r0)) => l0 == r0, + _ => false, + } + } +} + +impl<S> core::fmt::Debug for VisitResult<S> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + Self::Skipped(_) => f.debug_tuple("Skipped").finish(), + Self::Control(arg0) => f.debug_tuple("Control").field(arg0).finish(), + } + } +} + impl<S> From<Flow> for VisitResult<S> { fn from(value: Flow) -> Self { Self::Control(value) |