@@ -36,11 +36,11 @@ def is_err_and(&block)
3636 end
3737
3838 def ok
39- is_ok ? Some [ @value . class ] { @value } : None [ @value_type ]
39+ is_ok ? Some [ @value_type ] { @value } : None [ @value_type ]
4040 end
4141
4242 def err
43- is_err ? Some [ @error . class ] { @error } : None [ @error_type ]
43+ is_err ? Some [ @error_type ] { @error } : None [ @error_type ]
4444 end
4545
4646 def expect ( msg )
@@ -70,6 +70,7 @@ def unwrap_err
7070end
7171
7272class Ok < Rs ::Result
73+ attr_accessor :value_type
7374 attr_accessor :error_type
7475
7576 def self . []( value_type , error_type , &block )
@@ -96,11 +97,11 @@ def self.[](value_type, error_type, &block)
9697 end
9798
9899 def inspect
99- "Ok[#{ @value . class } , #{ @error_type } ] { #{ @value . inspect } }"
100+ "Ok[#{ @value_type } , #{ @error_type } ] { #{ @value . inspect } }"
100101 end
101102
102103 def ==( other )
103- other . is_a? ( Ok ) && @value == other . unwrap && @value . class == other . unwrap . class && @error_type == other . error_type
104+ other . is_a? ( Ok ) && @value == other . unwrap && @value_type == other . value_type && @error_type == other . error_type
104105 end
105106
106107 def initialize ( value )
@@ -109,12 +110,14 @@ def initialize(value)
109110 end
110111
111112 @value = value
113+ @value_type = value . class
112114 @error_type = Class
113115 end
114116end
115117
116118class Err < Rs ::Result
117119 attr_accessor :value_type
120+ attr_accessor :error_type
118121
119122 def self . []( value_type , error_type , &block )
120123 if !value_type . is_a? ( Class ) || !error_type . is_a? ( Class )
@@ -140,11 +143,11 @@ def self.[](value_type, error_type, &block)
140143 end
141144
142145 def inspect
143- "Err[#{ @value_type } , #{ @error . class } ] { #{ @error . inspect } }"
146+ "Err[#{ @value_type } , #{ @error_type } ] { #{ @error . inspect } }"
144147 end
145148
146149 def ==( other )
147- other . is_a? ( Err ) && @error == other . unwrap_err && @error . class == other . unwrap_err . class && @value_type == other . value_type
150+ other . is_a? ( Err ) && @error == other . unwrap_err && @value_type == other . value_type && @error_type == other . error_type
148151 end
149152
150153 def initialize ( error )
@@ -153,6 +156,7 @@ def initialize(error)
153156 end
154157
155158 @error = error
159+ @error_type = error . class
156160 @value_type = Class
157161 end
158162end
0 commit comments