Skip to content

Commit 665774c

Browse files
committed
impl Clone + Debug for core types + VariantDispatch
1 parent 0413391 commit 665774c

File tree

6 files changed

+22
-0
lines changed

6 files changed

+22
-0
lines changed

gdnative-core/src/core_types/dictionary.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,12 @@ where
544544
}
545545
}
546546

547+
impl Clone for Dictionary {
548+
fn clone(&self) -> Self {
549+
self.new_ref()
550+
}
551+
}
552+
547553
godot_test!(test_dictionary {
548554
use std::collections::HashSet;
549555

gdnative-core/src/core_types/node_path.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,10 @@ impl fmt::Debug for NodePath {
176176
write!(f, "NodePath({})", self.to_string())
177177
}
178178
}
179+
180+
impl Clone for NodePath {
181+
#[inline]
182+
fn clone(&self) -> Self {
183+
self.new_ref()
184+
}
185+
}

gdnative-core/src/core_types/rect2.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use super::Vector2;
22

3+
#[derive(Copy, Clone, Debug, PartialEq)]
34
#[repr(C)]
45
pub struct Rect2 {
56
pub position: Vector2,

gdnative-core/src/core_types/transform2d.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use super::Vector2;
22

3+
#[derive(Copy, Clone, Debug, PartialEq)]
34
#[repr(C)]
45
pub struct Transform2D {
56
pub x: Vector2,

gdnative-core/src/core_types/variant.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ macro_rules! decl_variant_type {
113113
///
114114
/// For `Variant`s containing objects, the original `Variant` is returned unchanged, due to
115115
/// the limitations of statically-determined memory management.
116+
#[derive(Clone, Debug)]
116117
#[repr(u32)]
117118
pub enum VariantDispatch {
118119
$(

gdnative-core/src/core_types/variant_array.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,12 @@ impl<T: ToVariant, Access: LocalThreadAccess> Extend<T> for VariantArray<Access>
588588
}
589589
}
590590

591+
impl Clone for VariantArray {
592+
fn clone(&self) -> Self {
593+
self.new_ref()
594+
}
595+
}
596+
591597
godot_test!(test_array {
592598
let foo = Variant::from_str("foo");
593599
let bar = Variant::from_str("bar");

0 commit comments

Comments
 (0)