From 18ed79b04c0e962e355685e0b1f564c5981d899e Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 28 Dec 2020 18:21:46 -0800 Subject: [PATCH] Add impl Debug for WeakPtr --- src/weak_ptr.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/weak_ptr.rs b/src/weak_ptr.rs index 3875a782..7fc4c78a 100644 --- a/src/weak_ptr.rs +++ b/src/weak_ptr.rs @@ -1,7 +1,7 @@ use crate::shared_ptr::{SharedPtr, SharedPtrTarget}; use crate::string::CxxString; use core::ffi::c_void; -use core::fmt::Display; +use core::fmt::{self, Debug, Display}; use core::marker::PhantomData; use core::mem::MaybeUninit; @@ -82,6 +82,15 @@ where } } +impl Debug for WeakPtr +where + T: Debug + WeakPtrTarget + SharedPtrTarget, +{ + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + Debug::fmt(&self.upgrade(), formatter) + } +} + // Methods are private; not intended to be implemented outside of cxxbridge // codebase. pub unsafe trait WeakPtrTarget {