@@ -84,8 +84,8 @@ impl FunctionSignature {
8484 let ty = field. signature_ty ( db) ;
8585 let raw_param = format ! ( "{}" , ty. display( db) ) ;
8686
87- if let Some ( param_type) = raw_param. split ( ':' ) . nth ( 1 ) {
88- parameter_types. push ( param_type[ 1 .. ] . to_string ( ) ) ;
87+ if let Some ( param_type) = raw_param. split ( ':' ) . nth ( 1 ) . and_then ( |it| it . get ( 1 .. ) ) {
88+ parameter_types. push ( param_type. to_string ( ) ) ;
8989 } else {
9090 // useful when you have tuple struct
9191 parameter_types. push ( raw_param. clone ( ) ) ;
@@ -129,8 +129,9 @@ impl FunctionSignature {
129129 for field in variant. fields ( db) . into_iter ( ) {
130130 let ty = field. signature_ty ( db) ;
131131 let raw_param = format ! ( "{}" , ty. display( db) ) ;
132- if let Some ( param_type) = raw_param. split ( ':' ) . nth ( 1 ) {
133- parameter_types. push ( param_type[ 1 ..] . to_string ( ) ) ;
132+ dbg ! ( & raw_param) ;
133+ if let Some ( param_type) = raw_param. split ( ':' ) . nth ( 1 ) . and_then ( |it| it. get ( 1 ..) ) {
134+ parameter_types. push ( param_type. to_string ( ) ) ;
134135 } else {
135136 // The unwrap_or_else is useful when you have tuple
136137 parameter_types. push ( raw_param) ;
@@ -197,16 +198,21 @@ impl From<&'_ ast::FnDef> for FunctionSignature {
197198 let raw_param = self_param. syntax ( ) . text ( ) . to_string ( ) ;
198199
199200 res_types. push (
200- raw_param. split ( ':' ) . nth ( 1 ) . unwrap_or_else ( || " Self" ) [ 1 ..] . to_string ( ) ,
201+ raw_param
202+ . split ( ':' )
203+ . nth ( 1 )
204+ . and_then ( |it| it. get ( 1 ..) )
205+ . unwrap_or_else ( || "Self" )
206+ . to_string ( ) ,
201207 ) ;
202208 res. push ( raw_param) ;
203209 }
204210
205211 res. extend ( param_list. params ( ) . map ( |param| param. syntax ( ) . text ( ) . to_string ( ) ) ) ;
206212 res_types. extend ( param_list. params ( ) . map ( |param| {
207213 let param_text = param. syntax ( ) . text ( ) . to_string ( ) ;
208- match param_text. split ( ':' ) . nth ( 1 ) {
209- Some ( it) => it[ 1 .. ] . to_string ( ) ,
214+ match param_text. split ( ':' ) . nth ( 1 ) . and_then ( |it| it . get ( 1 .. ) ) {
215+ Some ( it) => it. to_string ( ) ,
210216 None => param_text,
211217 }
212218 } ) ) ;
0 commit comments