소스 검색

implement copy for Resource

Evan Almloff 1 년 전
부모
커밋
81e0469cc2
1개의 변경된 파일7개의 추가작업 그리고 0개의 파일을 삭제
  1. 7 0
      packages/hooks/src/use_resource.rs

+ 7 - 0
packages/hooks/src/use_resource.rs

@@ -107,6 +107,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)]