Skip to content

Commit f7396f7

Browse files
Implement Clone and Copy for InterchangeRef
1 parent 63e9cd3 commit f7396f7

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,7 @@ pub struct InterchangeRef<'alloc, Rq, Rp> {
941941
channels: &'alloc [Channel<Rq, Rp>],
942942
last_claimed: &'alloc AtomicUsize,
943943
}
944+
944945
impl<'alloc, Rq, Rp> InterchangeRef<'alloc, Rq, Rp> {
945946
/// Claim one of the channels of the interchange. Returns None if called more than `N` times.
946947
pub fn claim(&self) -> Option<(Requester<'alloc, Rq, Rp>, Responder<'alloc, Rq, Rp>)> {
@@ -964,6 +965,14 @@ impl<'alloc, Rq, Rp> InterchangeRef<'alloc, Rq, Rp> {
964965
}
965966
}
966967

968+
impl<Rq, Rp> Clone for InterchangeRef<'_, Rq, Rp> {
969+
fn clone(&self) -> Self {
970+
*self
971+
}
972+
}
973+
974+
impl<Rq, Rp> Copy for InterchangeRef<'_, Rq, Rp> {}
975+
967976
impl<Rq, Rp, const N: usize> Default for Interchange<Rq, Rp, N> {
968977
fn default() -> Self {
969978
Self::new()

0 commit comments

Comments
 (0)