@@ -216,6 +216,13 @@ impl std::hash::Hash for TypeDescriptor {
216216 }
217217}
218218
219+ impl std:: fmt:: Display for TypeDescriptor {
220+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
221+ let text = make_type_user_readable ( & format_type ( & self . name ) ) ;
222+ write ! ( f, "{text}" )
223+ }
224+ }
225+
219226impl PartialEq for TypeDescriptor {
220227 fn eq ( & self , other : & Self ) -> bool {
221228 match ( self . id , other. id ) {
@@ -361,9 +368,13 @@ pub fn format_type(ty: &str) -> String {
361368 . join ( "<" )
362369}
363370
371+ pub fn make_type_user_readable ( ty : & str ) -> String {
372+ ty. replace ( "Option<Arc<OwnedContextImpl>>" , "Context" ) . replace ( "Vector<Option<Table<Graphic>>>" , "Vector" )
373+ }
374+
364375impl std:: fmt:: Debug for Type {
365376 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
366- let result = match self {
377+ let text = match self {
367378 Self :: Generic ( name) => name. to_string ( ) ,
368379 #[ cfg( feature = "type_id_logging" ) ]
369380 Self :: Concrete ( ty) => format ! ( "Concrete<{}, {:?}>" , ty. name, ty. id) ,
@@ -372,20 +383,20 @@ impl std::fmt::Debug for Type {
372383 Self :: Fn ( call_arg, return_value) => format ! ( "{return_value:?} called with {call_arg:?}" ) ,
373384 Self :: Future ( ty) => format ! ( "{ty:?}" ) ,
374385 } ;
375- let result = result . replace ( "Option<Arc<OwnedContextImpl>>" , "Context" ) ;
376- write ! ( f, "{result }" )
386+ let text = make_type_user_readable ( & text ) ;
387+ write ! ( f, "{text }" )
377388 }
378389}
379390
380391impl std:: fmt:: Display for Type {
381392 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
382- let result = match self {
393+ let text = match self {
383394 Type :: Generic ( name) => name. to_string ( ) ,
384395 Type :: Concrete ( ty) => format_type ( & ty. name ) ,
385396 Type :: Fn ( call_arg, return_value) => format ! ( "{return_value} called with {call_arg}" ) ,
386397 Type :: Future ( ty) => ty. to_string ( ) ,
387398 } ;
388- let result = result . replace ( "Option<Arc<OwnedContextImpl>>" , "Context" ) ;
389- write ! ( f, "{result }" )
399+ let text = make_type_user_readable ( & text ) ;
400+ write ! ( f, "{text }" )
390401 }
391402}
0 commit comments