Skip to content

Commit 7621068

Browse files
committed
feat(sdk): Implement Clone on LinkedChunkUpdate.
`LinkedChunkUpdate` implements `Clone` if and only if `Item` and `Gap` both implement `Clone`.
1 parent 3a00271 commit 7621068

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

crates/matrix-sdk/src/event_cache/linked_chunk.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,35 @@ pub enum LinkedChunkUpdate<Item, Gap> {
9696
},
9797
}
9898

99+
impl<Item, Gap> Clone for LinkedChunkUpdate<Item, Gap>
100+
where
101+
Item: Clone,
102+
Gap: Clone,
103+
{
104+
fn clone(&self) -> Self {
105+
match self {
106+
Self::NewItemsChunk { previous, new, next } => Self::NewItemsChunk {
107+
previous: previous.clone(),
108+
new: new.clone(),
109+
next: next.clone(),
110+
},
111+
Self::NewGapChunk { previous, new, next, gap } => Self::NewGapChunk {
112+
previous: previous.clone(),
113+
new: new.clone(),
114+
next: next.clone(),
115+
gap: gap.clone(),
116+
},
117+
Self::RemoveChunk(identifier) => Self::RemoveChunk(identifier.clone()),
118+
Self::InsertItems { at, items } => {
119+
Self::InsertItems { at: at.clone(), items: items.clone() }
120+
}
121+
Self::TruncateItems { chunk, length } => {
122+
Self::TruncateItems { chunk: chunk.clone(), length: length.clone() }
123+
}
124+
}
125+
}
126+
}
127+
99128
/// A collection of [`LinkedChunkUpdate`].
100129
///
101130
/// Get a value for this type with [`LinkedChunk::updates`].

0 commit comments

Comments
 (0)