<分区>
我有自己的自定义结构 - 事务,我希望可以复制它。
This fails because Vec does not implement Copy for any T. E0204
如何实现复制到 Vec 和我的结构。我要举个例子。
#[derive(PartialOrd, Eq, Hash)]
struct Transaction {
transaction_id: Vec<u8>,
proto_id: Vec<u8>,
len_field: Vec<u8>,
unit_id: u8,
func_nr: u8,
count_bytes: u8,
}
impl Copy for Transaction { }
impl Clone for Transaction {
fn clone(&self) -> Transaction {
*self
}
}
impl PartialEq for Transaction {
fn eq(&self, other: &Self) -> bool {
self.unit_id == other.unit_id
&& self.func_nr == other.func_nr
&& self.count_bytes == other.count_bytes
}
}
fn main()
{
}