Browse Source

Replace manual Debug traits implementation with macro, when possible, remove unnecessary ones

iorveth 4 years ago
parent
commit
3b9ef6b293

+ 0 - 36
runtime-modules/content-directory/src/operations.rs

@@ -16,12 +16,6 @@ pub enum ParametrizedPropertyValue<T: Trait> {
     InternalEntityVec(Vec<ParameterizedEntity<T>>),
 }
 
-impl<T: Trait> core::fmt::Debug for ParametrizedPropertyValue<T> {
-    fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
-        write!(formatter, "ParametrizedPropertyValue {:?}", self)
-    }
-}
-
 /// Parametrized entity
 #[derive(Encode, Decode, Eq, PartialEq, Clone)]
 pub enum ParameterizedEntity<T: Trait> {
@@ -29,12 +23,6 @@ pub enum ParameterizedEntity<T: Trait> {
     ExistingEntity(T::EntityId),
 }
 
-impl<T: Trait> core::fmt::Debug for ParameterizedEntity<T> {
-    fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
-        write!(formatter, "ParameterizedEntity {:?}", self)
-    }
-}
-
 /// Parametrized class property value
 #[derive(Encode, Decode, Eq, PartialEq, Clone)]
 pub struct ParametrizedClassPropertyValue<T: Trait> {
@@ -45,12 +33,6 @@ pub struct ParametrizedClassPropertyValue<T: Trait> {
     pub value: ParametrizedPropertyValue<T>,
 }
 
-impl<T: Trait> core::fmt::Debug for ParametrizedClassPropertyValue<T> {
-    fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
-        write!(formatter, "ParametrizedClassPropertyValue {:?}", self)
-    }
-}
-
 /// Operation, that represents `Entity` creation
 #[derive(Encode, Decode, Eq, PartialEq, Clone)]
 pub struct CreateEntityOperation<T: Trait> {
@@ -58,12 +40,6 @@ pub struct CreateEntityOperation<T: Trait> {
     pub class_id: T::ClassId,
 }
 
-impl<T: Trait> core::fmt::Debug for CreateEntityOperation<T> {
-    fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
-        write!(formatter, "CreateEntityOperation {:?}", self)
-    }
-}
-
 /// Operation, that represents property values update
 #[derive(Encode, Decode, Eq, PartialEq, Clone)]
 pub struct UpdatePropertyValuesOperation<T: Trait> {
@@ -73,12 +49,6 @@ pub struct UpdatePropertyValuesOperation<T: Trait> {
     pub new_parametrized_property_values: Vec<ParametrizedClassPropertyValue<T>>,
 }
 
-impl<T: Trait> core::fmt::Debug for UpdatePropertyValuesOperation<T> {
-    fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
-        write!(formatter, "UpdatePropertyValuesOperation {:?}", self)
-    }
-}
-
 /// Operation, that represents adding `Entity` `Schema` support
 #[derive(Encode, Decode, Eq, PartialEq, Clone)]
 pub struct AddSchemaSupportToEntityOperation<T: Trait> {
@@ -90,12 +60,6 @@ pub struct AddSchemaSupportToEntityOperation<T: Trait> {
     pub parametrized_property_values: Vec<ParametrizedClassPropertyValue<T>>,
 }
 
-impl<T: Trait> core::fmt::Debug for AddSchemaSupportToEntityOperation<T> {
-    fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
-        write!(formatter, "AddSchemaSupportToEntityOperation {:?}", self)
-    }
-}
-
 /// The type of operation performed
 #[derive(Encode, Decode, Eq, PartialEq, Clone)]
 pub enum OperationType<T: Trait> {

+ 3 - 21
runtime-modules/content-directory/src/schema.rs

@@ -42,7 +42,7 @@ pub struct PropertyLockingPolicy {
 
 /// Enum, used for `PropertyType` representation
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
-#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq)]
+#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, Debug)]
 pub enum Type<T: Trait> {
     Bool,
     Uint16,
@@ -58,12 +58,6 @@ pub enum Type<T: Trait> {
     Reference(T::ClassId, SameController),
 }
 
-impl<T: Trait> core::fmt::Debug for Type<T> {
-    fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
-        write!(formatter, "Type {:?}", self)
-    }
-}
-
 impl<T: Trait> Default for Type<T> {
     fn default() -> Self {
         Self::Bool
@@ -92,7 +86,7 @@ impl<T: Trait> Type<T> {
 }
 
 /// Vector property type representation
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
+#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
 #[derive(Encode, Decode, Clone, Copy, PartialEq, Eq)]
 pub struct VecPropertyType<T: Trait> {
     vec_type: Type<T>,
@@ -109,12 +103,6 @@ impl<T: Trait> Default for VecPropertyType<T> {
     }
 }
 
-impl<T: Trait> core::fmt::Debug for VecPropertyType<T> {
-    fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
-        write!(formatter, "VecPropertyType {:?}", self)
-    }
-}
-
 impl<T: Trait> VecPropertyType<T> {
     /// Create new `VecPropertyType` from provided `type` and `max_length`
     pub fn new(vec_type: Type<T>, max_length: VecMaxLength) -> Self {
@@ -147,18 +135,12 @@ impl<T: Trait> VecPropertyType<T> {
 
 /// Enum, representing either `Type` or `VecPropertyType`
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
-#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq)]
+#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, Debug)]
 pub enum PropertyType<T: Trait> {
     Single(Type<T>),
     Vector(VecPropertyType<T>),
 }
 
-impl<T: Trait> core::fmt::Debug for PropertyType<T> {
-    fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
-        write!(formatter, "PropertyType {:?}", self)
-    }
-}
-
 impl<T: Trait> Default for PropertyType<T> {
     fn default() -> Self {
         Self::Single(Type::default())

+ 1 - 7
runtime-modules/content-directory/src/schema/input.rs

@@ -104,7 +104,7 @@ impl<T: Trait> InputValue<T> {
 
 /// Vector value enum representation
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
-#[derive(Encode, Decode, Clone, PartialEq, Eq)]
+#[derive(Encode, Decode, Clone, PartialEq, Eq, Debug)]
 pub enum VecInputValue<T: Trait> {
     Bool(Vec<bool>),
     Uint16(Vec<u16>),
@@ -119,12 +119,6 @@ pub enum VecInputValue<T: Trait> {
     Reference(Vec<T::EntityId>),
 }
 
-impl<T: Trait> core::fmt::Debug for VecInputValue<T> {
-    fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
-        write!(formatter, "VecInputValue {:?}", self)
-    }
-}
-
 impl<T: Trait> Default for VecInputValue<T> {
     fn default() -> Self {
         Self::Bool(vec![])