diff options
| author | Sébastien Crozet <developer@crozet.re> | 2020-11-03 15:33:11 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-03 15:33:11 +0100 |
| commit | f70a840f79943aa6da49db2590e13dcd3f3a89ed (patch) | |
| tree | 1c743ed924b10ebd0eb0982e5c7d798235c12cee /src/data | |
| parent | 0cc850dc505a4034103d229fdce22f9ec7bc410a (diff) | |
| parent | 71611d3e30ce2fddee20832db3c3e0c8b6ba0d07 (diff) | |
| download | rapier-f70a840f79943aa6da49db2590e13dcd3f3a89ed.tar.gz rapier-f70a840f79943aa6da49db2590e13dcd3f3a89ed.tar.bz2 rapier-f70a840f79943aa6da49db2590e13dcd3f3a89ed.zip | |
Merge pull request #54 from dimforge/idiomatic_clone
Allow cloning all the physics components worth cloning
Diffstat (limited to 'src/data')
| -rw-r--r-- | src/data/graph.rs | 10 | ||||
| -rw-r--r-- | src/data/maybe_serializable_data.rs | 3 | ||||
| -rw-r--r-- | src/data/pubsub.rs | 3 |
3 files changed, 7 insertions, 9 deletions
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<N, E> IndexMut<EdgeIndex> for Graph<N, E> { /// 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> { 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<dyn MaybeSerializableData>; } 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<T> { // Position on the cursor array. id: u32, @@ -12,6 +13,7 @@ pub struct Subscription<T> { } #[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<T> { deleted_messages: u32, deleted_offsets: u32, |
