Skip to content
This repository was archived by the owner on Dec 2, 2022. It is now read-only.

Commit b28cbce

Browse files
committed
impl TableEncode for (A, B)
1 parent 898c415 commit b28cbce

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/kv/tables.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,22 @@ where
202202
}
203203
}
204204

205+
impl<A, B, const A_LEN: usize, const B_LEN: usize> TableEncode for (A, B)
206+
where
207+
A: TableEncode<Encoded = [u8; A_LEN]>,
208+
B: TableEncode<Encoded = [u8; B_LEN]>,
209+
[u8; A_LEN + B_LEN]: AsRef<[u8]>,
210+
{
211+
type Encoded = [u8; A_LEN + B_LEN];
212+
213+
fn encode(self) -> Self::Encoded {
214+
let mut v = [0; A_LEN + B_LEN];
215+
v[..A_LEN].copy_from_slice(&self.0.encode());
216+
v[A_LEN..].copy_from_slice(&self.1.encode());
217+
v
218+
}
219+
}
220+
205221
impl DupSort for PlainState {
206222
type SeekBothKey = Vec<u8>;
207223
}

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
destructuring_assignment,
44
entry_insert,
55
generic_associated_types,
6+
generic_const_exprs,
67
linked_list_cursors,
78
never_type,
89
step_trait,

0 commit comments

Comments
 (0)