@@ -216,7 +216,7 @@ fn get_key(data: &Value, key: KeyType) -> Option<Value> {
216
216
KeyType :: String ( k) => get_str_key ( data, k) ,
217
217
KeyType :: Number ( i) => match data {
218
218
Value :: Object ( _) => get_str_key ( data, i. to_string ( ) ) ,
219
- Value :: Array ( arr) => get ( arr, i) . map ( Value :: clone ) ,
219
+ Value :: Array ( arr) => get ( arr, i) . cloned ( ) ,
220
220
Value :: String ( s) => {
221
221
let s_vec: Vec < char > = s. chars ( ) . collect ( ) ;
222
222
get ( & s_vec, i) . map ( |c| c. to_string ( ) ) . map ( Value :: String )
@@ -236,14 +236,12 @@ fn get_str_key<K: AsRef<str>>(data: &Value, key: K) -> Option<Value> {
236
236
// Exterior ref in case we need to make a new value in the match.
237
237
k. split ( '.' ) . try_fold ( data. clone ( ) , |acc, i| match acc {
238
238
// If the current value is an object, try to get the value
239
- Value :: Object ( map) => map. get ( i) . map ( Value :: clone ) ,
239
+ Value :: Object ( map) => map. get ( i) . cloned ( ) ,
240
240
// If the current value is an array, we need an integer
241
241
// index. If integer conversion fails, return None.
242
- Value :: Array ( arr) => i
243
- . parse :: < i64 > ( )
244
- . ok ( )
245
- . and_then ( |i| get ( & arr, i) )
246
- . map ( Value :: clone) ,
242
+ Value :: Array ( arr) => {
243
+ i. parse :: < i64 > ( ) . ok ( ) . and_then ( |i| get ( & arr, i) ) . cloned ( )
244
+ }
247
245
// Same deal if it's a string.
248
246
Value :: String ( s) => {
249
247
let s_chars: Vec < char > = s. chars ( ) . collect ( ) ;
0 commit comments