message: [types] derive standard traits for EventKey
  Previously, an event key was 40 bytes long, and Rust doesn't let you derive
  these traits for a `[u8; 40]`. It does let you derive them for `[u8; 24]`
  though.
  Closes:
  Approved by: davidiw
diff: @@ -8,17 +8,13 @@ use proptest_derive::Arbitrary;
  #[cfg(feature = "fuzzing")]
  use rand::{rngs::OsRng, RngCore};
  use serde::{de, ser, Deserialize, Serialize};
  -use std::{
  - cmp::{Ord, Ordering, PartialOrd},
  - convert::TryFrom,
  - fmt,
  - hash::Hash,
  -};
  +use std::{convert::TryFrom, fmt};
  /// Size of an event key.
  pub const EVENT_KEY_LENGTH: usize = AccountAddress::LENGTH + 8;
  -/// A struct that represents a globally unique id for an Event stream that a user can listen to.
  +/// A struct that represents a globally unique id for an Event stream that a user can listen to.e
  +#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
  #[cfg_attr(feature = "fuzzing", derive(Arbitrary))]
  pub struct EventKey([u8; EVENT_KEY_LENGTH]);
  @@ -56,67 +52,6 @@ impl EventKey {
  }
  }
  -// Rust doesn't support deriving traits for array size greater than 32. We'll implement those traits
  -// by hand for now
  -impl PartialEq for EventKey {
  - #[inline]
  - fn eq(&self, other: &EventKey) -> bool {
  - self.as_bytes() == other.as_bytes()
  - }
  -}
  -
  -impl Eq for EventKey {}
  -
  -impl PartialOrd for EventKey {
  - fn partial_cmp(&self, other: &EventKey) -> Option<Ordering> {
  - PartialOrd::partial_cmp(self.as_bytes(), other.as_bytes())
  - }
  - #[inline]
  - fn lt(&self, other: &EventKey) -> bool {
  - PartialOrd::lt(self.as_bytes(), other.as_bytes())
  - }
  - #[inline]
  - fn le(&self, other: &EventKey) -> bool {
  - PartialOrd::le(self.as_bytes(), other.as_bytes())
  - }
  - #[inline]
  - fn ge(&self, other: &EventKey) -> bool {
  - PartialOrd::ge(self.as_bytes(), other.as_bytes())
  - }
  - #[inline]
  - fn gt(&self, other: &EventKey) -> bool {
  - PartialOrd::gt(self.as_bytes(), other.as_bytes())
  - }
  -}
  -
  -impl Ord for EventKey {
  - #[inline]
  - fn cmp(&self, other: &EventKey) -> Ordering {
  - Ord::cmp(self.as_bytes(), other.as_bytes())
  - }
  -}
  -
  -impl Clone for EventKey {
  - fn clone(&self) -> Self {
  - let mut key = [0; EVENT_KEY_LENGTH];
  - key.copy_from_slice(self.as_bytes());
  - Self(key)
  - }
  -}
  -
  -impl fmt::Debug for EventKey {
  - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
  - write!(f, "EventKey({:?})", self.as_bytes())
  - }
  -}
  -
  -impl Copy for EventKey {}
  -
  -impl Hash for EventKey {
  - fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
  - Hash::hash(self.as_bytes(), state)
  - }
  -}
  // TODO(#1307)
  impl ser::Serialize for EventKey {
  fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
  