Add impl Debug for WeakPtr

This commit is contained in:
David Tolnay 2020-12-28 18:21:46 -08:00
parent bc6e43c156
commit 18ed79b04c
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -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<T> Debug for WeakPtr<T>
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 {