@@ -118,11 +118,10 @@ impl NodeIOTypes {
118118
119119impl std:: fmt:: Debug for NodeIOTypes {
120120 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
121- f. write_fmt ( format_args ! (
122- "node({}) → {}" ,
123- [ & self . call_argument] . into_iter( ) . chain( & self . inputs) . map( |input| input. to_string( ) ) . collect:: <Vec <_>>( ) . join( ", " ) ,
124- self . return_value
125- ) )
121+ let inputs = self . inputs . iter ( ) . map ( ToString :: to_string) . collect :: < Vec < _ > > ( ) . join ( ", " ) ;
122+ let return_value = & self . return_value ;
123+ let call_argument = & self . call_argument ;
124+ f. write_fmt ( format_args ! ( "({inputs}) → {return_value} called with {call_argument}" ) )
126125 }
127126}
128127
@@ -202,7 +201,7 @@ impl std::hash::Hash for TypeDescriptor {
202201
203202impl std:: fmt:: Display for TypeDescriptor {
204203 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
205- let text = make_type_user_readable ( & format_type ( & self . name ) ) ;
204+ let text = make_type_user_readable ( & simplify_identifier_name ( & self . name ) ) ;
206205 write ! ( f, "{text}" )
207206 }
208207}
@@ -337,15 +336,17 @@ impl Type {
337336 }
338337 }
339338
340- pub fn to_cow_string ( & self ) -> Cow < ' static , str > {
339+ pub fn identifier_name ( & self ) -> String {
341340 match self {
342- Type :: Generic ( name) => name. clone ( ) ,
343- _ => Cow :: Owned ( self . to_string ( ) ) ,
341+ Type :: Generic ( name) => name. to_string ( ) ,
342+ Type :: Concrete ( ty) => simplify_identifier_name ( & ty. name ) ,
343+ Type :: Fn ( call_arg, return_value) => format ! ( "{} called with {}" , return_value. identifier_name( ) , call_arg. identifier_name( ) ) ,
344+ Type :: Future ( ty) => ty. identifier_name ( ) ,
344345 }
345346 }
346347}
347348
348- pub fn format_type ( ty : & str ) -> String {
349+ pub fn simplify_identifier_name ( ty : & str ) -> String {
349350 ty. split ( '<' )
350351 . map ( |path| path. split ( ',' ) . map ( |path| path. split ( "::" ) . last ( ) . unwrap_or ( path) ) . collect :: < Vec < _ > > ( ) . join ( "," ) )
351352 . collect :: < Vec < _ > > ( )
@@ -361,42 +362,26 @@ pub fn make_type_user_readable(ty: &str) -> String {
361362
362363impl std:: fmt:: Debug for Type {
363364 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
364- let text = match self {
365- Self :: Generic ( name) => name. to_string ( ) ,
366- #[ cfg( feature = "type_id_logging" ) ]
367- Self :: Concrete ( ty) => format ! ( "Concrete<{}, {:?}>" , ty. name, ty. id) ,
368- #[ cfg( not( feature = "type_id_logging" ) ) ]
369- Self :: Concrete ( ty) => format_type ( & ty. name ) ,
370- Self :: Fn ( call_arg, return_value) => format ! ( "{return_value:?} called with {call_arg:?}" ) ,
371- Self :: Future ( ty) => format ! ( "{ty:?}" ) ,
372- } ;
373- let text = make_type_user_readable ( & text) ;
374- write ! ( f, "{text}" )
365+ write ! ( f, "{self}" )
375366 }
376367}
377368
369+ // Display
378370impl std:: fmt:: Display for Type {
379371 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
380- if self == & concrete ! ( glam:: DVec2 ) {
381- return write ! ( f, "vec2" ) ;
382- }
383- if self == & concrete ! ( glam:: DAffine2 ) {
384- return write ! ( f, "transform" ) ;
385- }
386- if self == & concrete ! ( Footprint ) {
387- return write ! ( f, "footprint" ) ;
388- }
389- if self == & concrete ! ( & str ) || self == & concrete ! ( String ) {
390- return write ! ( f, "string" ) ;
391- }
372+ use glam:: * ;
392373
393- let text = match self {
394- Type :: Generic ( name) => name. to_string ( ) ,
395- Type :: Concrete ( ty) => format_type ( & ty. name ) ,
396- Type :: Fn ( call_arg, return_value) => format ! ( "{return_value} called with {call_arg}" ) ,
397- Type :: Future ( ty) => ty. to_string ( ) ,
398- } ;
399- let text = make_type_user_readable ( & text) ;
400- write ! ( f, "{text}" )
374+ match self {
375+ Type :: Generic ( name) => write ! ( f, "{}" , make_type_user_readable( name) ) ,
376+ Type :: Concrete ( ty) => match ( ) {
377+ ( ) if self == & concrete ! ( DVec2 ) || self == & concrete ! ( Vec2 ) || self == & concrete ! ( IVec2 ) || self == & concrete ! ( UVec2 ) => write ! ( f, "Vec2" ) ,
378+ ( ) if self == & concrete ! ( glam:: DAffine2 ) => write ! ( f, "Transform" ) ,
379+ ( ) if self == & concrete ! ( Footprint ) => write ! ( f, "Footprint" ) ,
380+ ( ) if self == & concrete ! ( & str ) || self == & concrete ! ( String ) => write ! ( f, "String" ) ,
381+ _ => write ! ( f, "{}" , make_type_user_readable( & simplify_identifier_name( & ty. name) ) ) ,
382+ } ,
383+ Type :: Fn ( call_arg, return_value) => write ! ( f, "{return_value} called with {call_arg}" ) ,
384+ Type :: Future ( ty) => write ! ( f, "{ty}" ) ,
385+ }
401386 }
402387}
0 commit comments