From 4da13cb1537e3441d45dee217d1fdc804e9f6a84 Mon Sep 17 00:00:00 2001 From: Arvid Gerstmann Date: Wed, 16 Oct 2024 15:13:27 +0000 Subject: [PATCH] chore: make all public types impl Debug --- ferrunix-core/src/registration.rs | 2 +- ferrunix-core/src/registry.rs | 15 +++++++++++++-- ferrunix/tests/it/main.rs | 1 + ferrunix/tests/it/validate_traits.rs | 13 +++++++++++++ 4 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 ferrunix/tests/it/validate_traits.rs diff --git a/ferrunix-core/src/registration.rs b/ferrunix-core/src/registration.rs index e41bade..736f731 100644 --- a/ferrunix-core/src/registration.rs +++ b/ferrunix-core/src/registration.rs @@ -24,7 +24,7 @@ thread_local! { /// /// This is, usually, used by the derive macro, and not manually. #[non_exhaustive] -#[allow(missing_debug_implementations)] +#[derive(Debug)] pub struct RegistrationFunc(pub(crate) fn(&Registry)); impl RegistrationFunc { diff --git a/ferrunix-core/src/registry.rs b/ferrunix-core/src/registry.rs index 3d26717..123e645 100644 --- a/ferrunix-core/src/registry.rs +++ b/ferrunix-core/src/registry.rs @@ -21,7 +21,6 @@ enum Object { } /// Registry for all types that can be constructed or otherwise injected. -#[allow(missing_debug_implementations)] pub struct Registry { objects: RwLock>, validation: RwLock>, @@ -230,8 +229,14 @@ impl Registry { } } +impl std::fmt::Debug for Registry { + fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + fmt.debug_struct("Registry").finish() + } +} + /// A builder for objects with dependencies. This can be created by using [`Registry::with_deps`]. -#[allow(missing_debug_implementations, clippy::single_char_lifetime_names)] +#[allow(clippy::single_char_lifetime_names)] pub struct Builder<'a, T, Deps> { registry: &'a Registry, _marker: PhantomData, @@ -361,3 +366,9 @@ where ); } } + +impl std::fmt::Debug for Builder<'_, T, Dep> { + fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + fmt.debug_struct("Builder").finish() + } +} diff --git a/ferrunix/tests/it/main.rs b/ferrunix/tests/it/main.rs index 02ccdc7..1367f67 100644 --- a/ferrunix/tests/it/main.rs +++ b/ferrunix/tests/it/main.rs @@ -5,3 +5,4 @@ mod common; mod derive_simple; mod manual; mod manual_traits; +mod validate_traits; diff --git a/ferrunix/tests/it/validate_traits.rs b/ferrunix/tests/it/validate_traits.rs new file mode 100644 index 0000000..b4c9f31 --- /dev/null +++ b/ferrunix/tests/it/validate_traits.rs @@ -0,0 +1,13 @@ +#![allow(clippy::no_effect)] +use ferrunix::registry::Builder; +use ferrunix::{Registry, Singleton, Transient}; + +struct IsDebug(Option); + +#[test] +fn all_public_types_are_debug() { + IsDebug::>(None); + IsDebug::>(None); + IsDebug::(None); + IsDebug::>(None); +}