Skip to content

Commit 94c1372

Browse files
authored
Allow cloning ComponentGraphs when nodes and edges are clonable (#7)
2 parents 4c4ee64 + 0294632 commit 94c1372

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313

1414
jobs:
1515
test:
16-
runs-on: ubuntu-20.04
16+
runs-on: ubuntu-24.04
1717

1818
steps:
1919
- name: Print environment (debug)

src/graph.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,23 @@ where
4343
config: ComponentGraphConfig,
4444
}
4545

46+
/// Implement `Clone` for `ComponentGraph` when the `Node`s and `Edge`s
47+
/// implement `Clone`.
48+
impl<N, E> Clone for ComponentGraph<N, E>
49+
where
50+
N: Node + Clone,
51+
E: Edge + Clone,
52+
{
53+
fn clone(&self) -> Self {
54+
Self {
55+
graph: self.graph.clone(),
56+
node_indices: self.node_indices.clone(),
57+
root_id: self.root_id,
58+
edges: self.edges.clone(),
59+
config: self.config.clone(),
60+
}
61+
}
62+
}
63+
4664
#[cfg(test)]
4765
mod test_utils;

0 commit comments

Comments
 (0)