From 26787df50d9de48a259e69c7f168dcb34ac18631 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Thu, 8 Aug 2019 08:28:14 -0500 Subject: [PATCH] refactor(checks): Implement traits for easier debugging --- src/checks.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/checks.rs b/src/checks.rs index 4c8b475d4..394188761 100644 --- a/src/checks.rs +++ b/src/checks.rs @@ -7,6 +7,7 @@ use crate::report; use crate::tokens; use crate::Dictionary; +#[derive(Debug, Clone, PartialEq, Eq)] pub struct CheckSettings { check_filenames: bool, check_files: bool, @@ -58,6 +59,7 @@ impl Default for CheckSettings { } } +#[derive(Clone)] pub struct Checks<'d, 'p> { dictionary: &'d Dictionary, parser: &'p tokens::Parser, @@ -170,3 +172,14 @@ impl<'d, 'p> Checks<'d, 'p> { Ok(typos_found) } } + +impl std::fmt::Debug for Checks<'_, '_> { + fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result { + fmt.debug_struct("Checks") + .field("parser", self.parser) + .field("check_filenames", &self.check_filenames) + .field("check_files", &self.check_files) + .field("binary", &self.binary) + .finish() + } +}