@@ -67,7 +67,8 @@ defprotocol Inspect do
6767    * `:optional` - (since v1.14.0) a list of fields that should not be 
6868      included when they match their default value. This can be used to 
6969      simplify the struct representation at the cost of hiding 
70-       information. 
70+       information. Since v1.19.0, the `:all` atom can be passed to 
71+       mark all fields as optional. 
7172
7273  Whenever `:only` or `:except` are used to restrict fields, 
7374  the struct will be printed using the `#User<...>` notation, 
@@ -159,11 +160,19 @@ defprotocol Inspect do
159160
160161    only  =  Keyword . get ( options ,  :only ,  fields ) 
161162    except  =  Keyword . get ( options ,  :except ,  [ ] ) 
162-     optional  =  Keyword . get ( options ,  :optional ,  [ ] ) 
163163
164164    :ok  =  validate_option ( :only ,  only ,  fields ,  module ) 
165165    :ok  =  validate_option ( :except ,  except ,  fields ,  module ) 
166-     :ok  =  validate_option ( :optional ,  optional ,  fields ,  module ) 
166+ 
167+     optional  = 
168+       case  Keyword . get ( options ,  :optional ,  [ ] )  do 
169+         :all  -> 
170+           fields 
171+ 
172+         optional  -> 
173+           :ok  =  validate_option ( :optional ,  optional ,  fields ,  module ) 
174+           optional 
175+       end 
167176
168177    inspect_module  = 
169178      if  fields  ==  Enum . sort ( only )  and  except  ==  [ ]  do 
0 commit comments