@@ -216,7 +216,7 @@ fn get_key(data: &Value, key: KeyType) -> Option<Value> {
216216 KeyType :: String ( k) => get_str_key ( data, k) ,
217217 KeyType :: Number ( i) => match data {
218218 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 ( ) ,
220220 Value :: String ( s) => {
221221 let s_vec: Vec < char > = s. chars ( ) . collect ( ) ;
222222 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> {
236236 // Exterior ref in case we need to make a new value in the match.
237237 k. split ( '.' ) . try_fold ( data. clone ( ) , |acc, i| match acc {
238238 // 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 ( ) ,
240240 // If the current value is an array, we need an integer
241241 // 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+ }
247245 // Same deal if it's a string.
248246 Value :: String ( s) => {
249247 let s_chars: Vec < char > = s. chars ( ) . collect ( ) ;
0 commit comments