Debug for WeakDynamic

This commit is contained in:
Jonathan Johnson 2023-12-21 07:11:24 -08:00
parent 2ad583926b
commit 641ae3a17d
No known key found for this signature in database
GPG key ID: A66D6A34D6620579
2 changed files with 15 additions and 0 deletions

View file

@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
This dynamic is also accessible through `RunningWindow::inner_size`, which is
accessible through contexts passed into various `Widget` functions.
- `Progress` now implements `Default` by returning `Progress::Indeterminant`.
- `WeakDynamic<T>` now implements `Debug` when `T` is `Debug`.
### Fixed

View file

@ -1205,6 +1205,20 @@ impl<T> WeakDynamic<T> {
self.0.upgrade().map(Dynamic)
}
}
impl<T> Debug for WeakDynamic<T>
where
T: Debug,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if let Some(strong) = self.upgrade() {
Debug::fmt(&strong, f)
} else {
f.debug_tuple("WeakDynamic")
.field(&"<pending drop>")
.finish()
}
}
}
impl<'a, T> From<&'a Dynamic<T>> for WeakDynamic<T> {
fn from(value: &'a Dynamic<T>) -> Self {