Merge pull request #2064 from ealmloff/make-resource-copy

Implement copy for Resource
This commit is contained in:
Jonathan Kelley authored and GitHub committed 2024-03-12 13:32:31 -07:00
commit d180f569cf
2 files changed
+17 -6

No files matched your search

+7
View File
@@ -119,6 +119,13 @@ pub struct Resource<T: 'static> {
callback: UseCallback<Task>,
}
impl<T> Clone for Resource<T> {
fn clone(&self) -> Self {
*self
}
}
impl<T> Copy for Resource<T> {}
/// A signal that represents the state of the resource
// we might add more states (panicked, etc)
#[derive(Clone, Copy, PartialEq, Hash, Eq, Debug)]
+10 -6
View File
@@ -244,12 +244,16 @@ impl<'a> ToTokens for TemplateRenderer<'a> {
attr_paths: &[ #(#attr_paths),* ],
};
dioxus_core::VNode::new(
#key_tokens,
TEMPLATE,
Box::new([ #( #node_printer),* ]),
Box::new([ #(#dyn_attr_printer),* ]),
)
{
// NOTE: Allocating a temporary is important to make reads within rsx drop before the value is returned
let __vnodes = dioxus_core::VNode::new(
#key_tokens,
TEMPLATE,
Box::new([ #( #node_printer),* ]),
Box::new([ #(#dyn_attr_printer),* ]),
);
__vnodes
}
});
}
}