Skip to content

Commit a82570f

Browse files
Implement Clone and Copy for InterchangeRef
1 parent 78306b4 commit a82570f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9-
### Changed
9+
### Added
10+
11+
- Add `Clone` and `Copy` implementations for `InterchangeRef`.
1012

1113
## [0.3.1][] - 2024-06-20
1214

src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,7 @@ pub struct InterchangeRef<'alloc, Rq, Rp> {
935935
channels: &'alloc [Channel<Rq, Rp>],
936936
last_claimed: &'alloc AtomicUsize,
937937
}
938+
938939
impl<'alloc, Rq, Rp> InterchangeRef<'alloc, Rq, Rp> {
939940
/// Claim one of the channels of the interchange. Returns None if called more than `N` times.
940941
pub fn claim(&self) -> Option<(Requester<'alloc, Rq, Rp>, Responder<'alloc, Rq, Rp>)> {
@@ -958,6 +959,17 @@ impl<'alloc, Rq, Rp> InterchangeRef<'alloc, Rq, Rp> {
958959
}
959960
}
960961

962+
impl<Rq, Rp> Clone for InterchangeRef<'_, Rq, Rp> {
963+
fn clone(&self) -> Self {
964+
Self {
965+
channels: self.channels,
966+
last_claimed: self.last_claimed,
967+
}
968+
}
969+
}
970+
971+
impl<Rq, Rp> Copy for InterchangeRef<'_, Rq, Rp> {}
972+
961973
#[cfg(not(loom))]
962974
impl<Rq, Rp, const N: usize> Default for Interchange<Rq, Rp, N> {
963975
fn default() -> Self {

0 commit comments

Comments
 (0)