Skip to content

Commit 39db843

Browse files
authored
Implement Copy and Clone for Handle<T> where T: !Copy (#563)
Signed-off-by: Greg Morenz <[email protected]>
1 parent e0e1836 commit 39db843

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

mozjs/src/gc/root.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,18 @@ impl<'a, const N: usize> From<&RootedGuard<'a, ValueArray<N>>> for JS::HandleVal
100100
}
101101
}
102102

103-
#[derive(Clone, Copy)]
104103
pub struct Handle<'a, T: 'a> {
105104
pub(crate) ptr: &'a T,
106105
}
107106

107+
impl<T> Clone for Handle<'_, T> {
108+
fn clone(&self) -> Self {
109+
*self
110+
}
111+
}
112+
113+
impl<T> Copy for Handle<'_, T> {}
114+
108115
pub struct MutableHandle<'a, T: 'a> {
109116
pub(crate) ptr: *mut T,
110117
anchor: PhantomData<&'a mut T>,

0 commit comments

Comments
 (0)