fix the context API

This commit is contained in:
Evan Almloff committed 2023-08-04 14:42:19 -07:00
1 parent 2b6b3b67b1
commit 0be5dbe715
2 files changed
+8 -7

No files matched your search

+3 -5
View File
@@ -115,21 +115,19 @@ impl ScopeContext {
let mut search_parent = self.parent_id;
with_runtime(|runtime| {
let mut result = None;
while let Some(parent_id) = search_parent {
let parent = runtime.get_context(parent_id).unwrap();
if let Some(shared) = parent
.shared_contexts
.borrow()
.iter()
.find(|(k, _)| *k == TypeId::of::<T>())
.find_map(|(_, any)| any.downcast_ref::<T>())
{
result = shared.1.downcast_ref::<T>().cloned();
break;
return Some(shared.clone());
}
search_parent = parent.parent_id;
}
result
None
})
.flatten()
}