From 52b4f86eee7ee52d07db515ee2fa3993b9d95541 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Tue, 17 Jul 2018 13:21:28 +1000 Subject: [PATCH] Implement Eq and Clone for bool bitfield --- src/utils/boolean_bitfield.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/utils/boolean_bitfield.rs b/src/utils/boolean_bitfield.rs index fd51bff321..bb7fa79bcc 100644 --- a/src/utils/boolean_bitfield.rs +++ b/src/utils/boolean_bitfield.rs @@ -10,6 +10,7 @@ extern crate rlp; use std::cmp::max; use self::rlp::{ RlpStream, Encodable }; +#[derive(Eq)] pub struct BooleanBitfield{ len: usize, vec: Vec @@ -82,6 +83,23 @@ impl BooleanBitfield { } } +impl PartialEq for BooleanBitfield { + fn eq(&self, other: &BooleanBitfield) -> bool { + (self.vec == other.vec) & + (self.len == other.len) + } +} + +impl Clone for BooleanBitfield { + fn clone(&self) -> Self { + Self { + vec: self.vec.to_vec(), + ..*self + } + } +} + + impl Encodable for BooleanBitfield { // TODO: ensure this is a sensible method of encoding // the bitfield. Currently, it is treated as a list of