convert T into signals automatically

This commit is contained in:
Evan Almloff committed 2024-01-29 13:36:39 -06:00
1 parent 1847c737e9
commit 50e3216d8b
14 files changed
+441 -103

No files matched your search

+8 -1
View File
@@ -72,7 +72,7 @@ impl AnyStorage for SyncStorage {
self.0.data_ptr() as *const ()
}
fn take(&self) -> bool {
fn manually_drop(&self) -> bool {
self.0.write().take().is_some()
}
@@ -162,4 +162,11 @@ impl<T: Sync + Send + 'static> Storage<T> for SyncStorage {
fn set(&self, value: T) {
*self.0.write() = Some(Box::new(value));
}
fn take(&'static self) -> Option<T> {
self.0
.write()
.take()
.and_then(|any| any.downcast().ok().map(|boxed| *boxed))
}
}