From 036a24614171eff0f99495b8b6f1c09e58cb4f9a Mon Sep 17 00:00:00 2001 From: Crozet Sébastien Date: Tue, 3 Nov 2020 14:29:47 +0100 Subject: Make cloning rigid-bodies and colliders more idiomatic. Fix #53 --- src/data/graph.rs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'src/data') diff --git a/src/data/graph.rs b/src/data/graph.rs index ea27e03..de958c3 100644 --- a/src/data/graph.rs +++ b/src/data/graph.rs @@ -749,20 +749,12 @@ impl IndexMut for Graph { /// The walker does not borrow from the graph, so it lets you step through /// neighbors or incident edges while also mutating graph weights, as /// in the following example: +#[derive(Clone)] pub struct WalkNeighbors { skip_start: NodeIndex, next: [EdgeIndex; 2], } -impl Clone for WalkNeighbors { - fn clone(&self) -> Self { - WalkNeighbors { - skip_start: self.skip_start, - next: self.next, - } - } -} - /// Reference to a `Graph` edge. #[derive(Debug)] pub struct EdgeReference<'a, E: 'a> { -- cgit From 0cf59d78bda1669226f861e438d43a08b099d747 Mon Sep 17 00:00:00 2001 From: Crozet Sébastien Date: Tue, 3 Nov 2020 14:43:21 +0100 Subject: Implement Clone for everything that can be cloned. --- src/data/maybe_serializable_data.rs | 3 +++ src/data/pubsub.rs | 3 +++ 2 files changed, 6 insertions(+) (limited to 'src/data') diff --git a/src/data/maybe_serializable_data.rs b/src/data/maybe_serializable_data.rs index db38963..8b14e1a 100644 --- a/src/data/maybe_serializable_data.rs +++ b/src/data/maybe_serializable_data.rs @@ -9,6 +9,9 @@ pub trait MaybeSerializableData: DowncastSync { fn as_serialize(&self) -> Option<(u32, &dyn Serialize)> { None } + + /// Clones `self`. + fn clone_dyn(&self) -> Box; } impl_downcast!(sync MaybeSerializableData); diff --git a/src/data/pubsub.rs b/src/data/pubsub.rs index b2c9e27..80fb3a2 100644 --- a/src/data/pubsub.rs +++ b/src/data/pubsub.rs @@ -5,6 +5,7 @@ use std::marker::PhantomData; /// A permanent subscription to a pub-sub queue. #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] +#[derive(Clone)] pub struct Subscription { // Position on the cursor array. id: u32, @@ -12,6 +13,7 @@ pub struct Subscription { } #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] +#[derive(Clone)] struct PubSubCursor { // Position on the offset array. id: u32, @@ -36,6 +38,7 @@ impl PubSubCursor { /// A pub-sub queue. #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] +#[derive(Clone)] pub struct PubSub { deleted_messages: u32, deleted_offsets: u32, -- cgit