Skip to content

Commit eb6520c

Browse files
author
Dylan McKay
committed
Derive PartialEq for all parcel types
1 parent de964f3 commit eb6520c

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "protocol"
3-
version = "0.1.9"
3+
version = "0.1.10"
44
authors = ["Dylan McKay <dylanmckay34@gmail.com>"]
55

66
description = "Easy protocol definitions"

src/packet/macros.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ macro_rules! define_packet
44
{
55
// Define a normal packet.
66
( $ty:ident { $( $field_name:ident : $field_ty:ty),+ }) => {
7-
#[derive(Clone, Debug)]
7+
#[derive(Clone, Debug, PartialEq)]
88
pub struct $ty
99
{
1010
$( pub $field_name : $field_ty ),+
@@ -34,7 +34,7 @@ macro_rules! define_packet
3434

3535
// Define an empty packet.
3636
( $ty:ident ) => {
37-
#[derive(Clone, Debug)]
37+
#[derive(Clone, Debug, PartialEq)]
3838
pub struct $ty;
3939

4040
impl $crate::Parcel for $ty
@@ -57,7 +57,7 @@ macro_rules! define_packet
5757
macro_rules! define_packet_kind
5858
{
5959
( $ty:ident : $id_ty:ty { $( $packet_id:expr => $packet_ty:ident ),+ } ) => {
60-
#[derive(Clone, Debug)]
60+
#[derive(Clone, Debug, PartialEq)]
6161
pub enum $ty
6262
{
6363
$( $packet_ty($packet_ty) ),+

src/parcel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::io::prelude::*;
22
use std::{fmt, io};
33

44
/// A value which can be read and written.
5-
pub trait Parcel : Clone + fmt::Debug
5+
pub trait Parcel : Clone + fmt::Debug + PartialEq
66
{
77
/// Reads a value from a stream.
88
fn read(read: &mut Read) -> Result<Self, ::Error>;

src/primitives/array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl<T: Parcel> Parcel for Vec<T>
1717
}
1818

1919
/// An array type with a custom size prefix type.
20-
#[derive(Clone, Debug)]
20+
#[derive(Clone, Debug, PartialEq)]
2121
pub struct Array<S: primitives::Integer, T: Parcel>
2222
{
2323
pub elements: Vec<T>,

src/primitives/composite.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ macro_rules! implement_composite_type {
3939
#[macro_export]
4040
macro_rules! define_composite_type {
4141
($ty:ident { $( $field_name:ident : $field_ty:ty ),+ }) => {
42-
#[derive(Clone,Debug, PartialEq)]
42+
#[derive(Clone, Debug, PartialEq)]
4343
pub struct $ty
4444
{
4545
$( pub $field_name : $field_ty ),+
@@ -58,7 +58,7 @@ mod test
5858
pub use Parcel;
5959
pub use std::io::Cursor;
6060

61-
#[derive(Clone, Debug)]
61+
#[derive(Clone, Debug, PartialEq)]
6262
pub struct Foo
6363
{
6464
baz: String,

src/primitives/string.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl Parcel for std::string::String
1919

2020
/// A string with a custom size prefix integer type.
2121
/// `S` - The size prefix type.
22-
#[derive(Clone, Debug)]
22+
#[derive(Clone, Debug, PartialEq)]
2323
pub struct String<S: primitives::Integer = u32>
2424
{
2525
pub value: std::string::String,

0 commit comments

Comments
 (0)