diff --git a/lib/xdr/struct.rb b/lib/xdr/struct.rb
index <HASH>..<HASH> 100644
--- a/lib/xdr/struct.rb
+++ b/lib/xdr/struct.rb
@@ -9,7 +9,7 @@ class XDR::Struct
 
   attribute_method_prefix 'read_'
   attribute_method_suffix 'write_'
-  
+
   class_attribute :fields
   self.fields = ActiveSupport::OrderedHash.new
 
@@ -68,6 +68,14 @@ class XDR::Struct
     other.attributes == self.attributes
   end
 
+  def eql? (other)
+    return false unless other.is_a?(self.class)
+    other.attributes.eql? self.attributes
+  end
+
+  def hash
+    [self.class, self.attribues].hash
+  end
 
   def read_attribute(attr)
     @attributes[attr]
diff --git a/lib/xdr/union.rb b/lib/xdr/union.rb
index <HASH>..<HASH> 100644
--- a/lib/xdr/union.rb
+++ b/lib/xdr/union.rb
@@ -114,6 +114,16 @@ class XDR::Union
     other.value == self.value
   end
 
+  def eql?(other)
+    return false unless other.is_a?(self.class)
+    return false unless other.switch.eql? self.switch
+    other.value.eql? self.value
+  end
+  
+  def hash
+    [self.class, self.switch, self.value].hash
+  end
+
   private
   def valid_for_arm_type(value, arm)
     arm_type = arms[@arm]
Add eql? and hash implementations for struct and union

Allows for `uniq` to behave as expected