@@ -32,15 +32,15 @@ pub fn process_captures(captures: &SerializableCaptures) -> Vec<(String, String,
3232/// that should be paired with a secret key.
3333pub fn find_closest_variable (
3434 captures : & [ ( String , String , usize , usize ) ] ,
35- target_value : & String ,
35+ target_value : & str ,
3636 target_variable_name : & str ,
3737 search_variable_name : & str ,
3838) -> Option < String > {
3939 // Collect the positions of the target variable for the provided value so we can
4040 // compare relative offsets with candidate variables.
4141 let mut target_positions = Vec :: new ( ) ;
4242 for ( name, value, start, end) in captures {
43- if name == target_variable_name && value == target_value {
43+ if name == target_variable_name && value. as_str ( ) == target_value {
4444 target_positions. push ( ( * start, * end) ) ;
4545 }
4646 }
@@ -138,8 +138,7 @@ mod tests {
138138 ( "AKID" . to_string( ) , "following" . to_string( ) , 180usize , 200usize ) ,
139139 ] ;
140140
141- let result =
142- find_closest_variable ( & captures, & "secret" . to_string ( ) , "TOKEN" , "AKID" ) . unwrap ( ) ;
141+ let result = find_closest_variable ( & captures, "secret" , "TOKEN" , "AKID" ) . unwrap ( ) ;
143142
144143 assert_eq ! ( result, "preceding" . to_string( ) ) ;
145144 }
@@ -151,8 +150,7 @@ mod tests {
151150 ( "AKID" . to_string( ) , "after" . to_string( ) , 60usize , 80usize ) ,
152151 ] ;
153152
154- let result =
155- find_closest_variable ( & captures, & "secret" . to_string ( ) , "TOKEN" , "AKID" ) . unwrap ( ) ;
153+ let result = find_closest_variable ( & captures, "secret" , "TOKEN" , "AKID" ) . unwrap ( ) ;
156154
157155 assert_eq ! ( result, "after" . to_string( ) ) ;
158156 }
0 commit comments