aboutsummaryrefslogtreecommitdiff
path: root/src/castable_factory/threadsafe.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/castable_factory/threadsafe.rs')
-rw-r--r--src/castable_factory/threadsafe.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/castable_factory/threadsafe.rs b/src/castable_factory/threadsafe.rs
index 8f9c072..c1a90c4 100644
--- a/src/castable_factory/threadsafe.rs
+++ b/src/castable_factory/threadsafe.rs
@@ -1,3 +1,6 @@
+use std::any::type_name;
+use std::fmt::Debug;
+
use crate::interfaces::any_factory::{AnyFactory, AnyThreadsafeFactory};
use crate::interfaces::factory::IThreadsafeFactory;
use crate::ptr::TransientPtr;
@@ -86,6 +89,39 @@ where
{
}
+impl<Args, ReturnInterface> Debug for ThreadsafeCastableFactory<Args, ReturnInterface>
+where
+ Args: 'static,
+ ReturnInterface: 'static + ?Sized,
+{
+ #[cfg(not(tarpaulin_include))]
+ fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result
+ {
+ let mut args = type_name::<Args>();
+
+ if args.len() < 2 {
+ return Err(std::fmt::Error::default());
+ }
+
+ args = args
+ .get(1..args.len() - 1)
+ .map_or_else(|| Err(std::fmt::Error::default()), Ok)?;
+
+ if args.ends_with(',') {
+ args = args
+ .get(..args.len() - 1)
+ .map_or_else(|| Err(std::fmt::Error), Ok)?;
+ }
+
+ let ret = type_name::<TransientPtr<ReturnInterface>>();
+
+ formatter.write_fmt(format_args!(
+ "ThreadsafeCastableFactory ({}) -> {}",
+ args, ret
+ ))
+ }
+}
+
#[cfg(test)]
mod tests
{