@@ -18,7 +18,6 @@ use std::ptr;
1818
1919use jni_sys:: { jobject, JNIEnv } ;
2020use serde:: Serialize ;
21- use serde_json;
2221
2322use crate :: api:: instance:: Instance ;
2423use crate :: api:: { JavaClass , Jvm , Null } ;
@@ -153,7 +152,7 @@ impl InvocationArg {
153152 } else {
154153 let json = serde_json:: to_string ( arg) ?;
155154 Ok ( InvocationArg :: Rust {
156- json : json ,
155+ json,
157156 class_name : class_name. to_string ( ) ,
158157 serialized : true ,
159158 } )
@@ -163,18 +162,18 @@ impl InvocationArg {
163162 fn make_primitive ( & mut self ) -> errors:: Result < ( ) > {
164163 match utils:: primitive_of ( self ) {
165164 Some ( primitive_repr) => {
166- match self {
167- & mut InvocationArg :: Java {
165+ match * self {
166+ InvocationArg :: Java {
168167 instance : _,
169168 ref mut class_name,
170169 serialized : _,
171170 } => * class_name = primitive_repr,
172- & mut InvocationArg :: Rust {
171+ InvocationArg :: Rust {
173172 json : _,
174173 ref mut class_name,
175174 serialized : _,
176175 } => * class_name = primitive_repr,
177- & mut InvocationArg :: RustBasic {
176+ InvocationArg :: RustBasic {
178177 instance : _,
179178 ref mut class_name,
180179 serialized : _,
@@ -184,7 +183,7 @@ impl InvocationArg {
184183 }
185184 None => Err ( errors:: J4RsError :: JavaError ( format ! (
186185 "Cannot transform to primitive: {}" ,
187- utils:: get_class_name( & self )
186+ utils:: get_class_name( self )
188187 ) ) ) ,
189188 }
190189 }
@@ -203,13 +202,13 @@ impl InvocationArg {
203202 pub fn as_java_ptr_with_global_ref ( & self , jni_env : * mut JNIEnv ) -> errors:: Result < jobject > {
204203 match self {
205204 _s @ & InvocationArg :: Java { .. } => {
206- jni_utils:: invocation_arg_jobject_from_java ( & self , jni_env, true )
205+ jni_utils:: invocation_arg_jobject_from_java ( self , jni_env, true )
207206 }
208207 _s @ & InvocationArg :: Rust { .. } => {
209- jni_utils:: invocation_arg_jobject_from_rust_serialized ( & self , jni_env, true )
208+ jni_utils:: invocation_arg_jobject_from_rust_serialized ( self , jni_env, true )
210209 }
211210 _s @ & InvocationArg :: RustBasic { .. } => {
212- jni_utils:: invocation_arg_jobject_from_rust_basic ( & self , jni_env, true )
211+ jni_utils:: invocation_arg_jobject_from_rust_basic ( self , jni_env, true )
213212 }
214213 }
215214 }
@@ -218,13 +217,13 @@ impl InvocationArg {
218217 pub fn as_java_ptr_with_local_ref ( & self , jni_env : * mut JNIEnv ) -> errors:: Result < jobject > {
219218 match self {
220219 _s @ & InvocationArg :: Java { .. } => {
221- jni_utils:: invocation_arg_jobject_from_java ( & self , jni_env, false )
220+ jni_utils:: invocation_arg_jobject_from_java ( self , jni_env, false )
222221 }
223222 _s @ & InvocationArg :: Rust { .. } => {
224- jni_utils:: invocation_arg_jobject_from_rust_serialized ( & self , jni_env, false )
223+ jni_utils:: invocation_arg_jobject_from_rust_serialized ( self , jni_env, false )
225224 }
226225 _s @ & InvocationArg :: RustBasic { .. } => {
227- jni_utils:: invocation_arg_jobject_from_rust_basic ( & self , jni_env, false )
226+ jni_utils:: invocation_arg_jobject_from_rust_basic ( self , jni_env, false )
228227 }
229228 }
230229 }
@@ -233,30 +232,26 @@ impl InvocationArg {
233232 pub fn instance ( self ) -> errors:: Result < Instance > {
234233 match self {
235234 InvocationArg :: Java { instance : i, .. } => Ok ( i) ,
236- InvocationArg :: RustBasic { .. } => Err ( errors:: J4RsError :: RustError ( format ! (
237- "Invalid operation: Cannot get the instance of an InvocationArg::RustBasic"
238- ) ) ) ,
239- InvocationArg :: Rust { .. } => Err ( errors:: J4RsError :: RustError ( format ! (
240- "Cannot get the instance from an InvocationArg::Rust"
241- ) ) ) ,
235+ InvocationArg :: RustBasic { .. } => Err ( errors:: J4RsError :: RustError ( "Invalid operation: Cannot get the instance of an InvocationArg::RustBasic" . to_string ( ) ) ) ,
236+ InvocationArg :: Rust { .. } => Err ( errors:: J4RsError :: RustError ( "Cannot get the instance from an InvocationArg::Rust" . to_string ( ) ) ) ,
242237 }
243238 }
244239
245240 pub fn class_name ( & self ) -> & str {
246241 match self {
247- & InvocationArg :: Java {
242+ InvocationArg :: Java {
248243 instance : _,
249- ref class_name,
244+ class_name,
250245 serialized : _,
251246 } => class_name,
252- & InvocationArg :: Rust {
247+ InvocationArg :: Rust {
253248 json : _,
254- ref class_name,
249+ class_name,
255250 serialized : _,
256251 } => class_name,
257- & InvocationArg :: RustBasic {
252+ InvocationArg :: RustBasic {
258253 instance : _,
259- ref class_name,
254+ class_name,
260255 serialized : _,
261256 } => class_name,
262257 }
@@ -291,8 +286,8 @@ impl From<Instance> for InvocationArg {
291286 let class_name = instance. class_name . to_owned ( ) ;
292287
293288 InvocationArg :: Java {
294- instance : instance ,
295- class_name : class_name ,
289+ instance,
290+ class_name,
296291 serialized : false ,
297292 }
298293 }
@@ -331,7 +326,7 @@ impl<'a> TryFrom<&'a [String]> for InvocationArg {
331326 fn try_from ( vec : & ' a [ String ] ) -> errors:: Result < InvocationArg > {
332327 let args: errors:: Result < Vec < InvocationArg > > = vec
333328 . iter ( )
334- . map ( |elem| InvocationArg :: try_from ( elem ) )
329+ . map ( InvocationArg :: try_from)
335330 . collect ( ) ;
336331 let res =
337332 Jvm :: do_create_java_list ( cache:: get_thread_local_env ( ) ?, cache:: J4RS_ARRAY , & args?) ;
@@ -379,7 +374,7 @@ impl<'a> TryFrom<&'a [bool]> for InvocationArg {
379374 fn try_from ( vec : & ' a [ bool ] ) -> errors:: Result < InvocationArg > {
380375 let args: errors:: Result < Vec < InvocationArg > > = vec
381376 . iter ( )
382- . map ( |elem| InvocationArg :: try_from ( elem ) )
377+ . map ( InvocationArg :: try_from)
383378 . collect ( ) ;
384379 let res =
385380 Jvm :: do_create_java_list ( cache:: get_thread_local_env ( ) ?, cache:: J4RS_ARRAY , & args?) ;
@@ -399,7 +394,7 @@ impl<'a> TryFrom<&'a [i8]> for InvocationArg {
399394 fn try_from ( vec : & ' a [ i8 ] ) -> errors:: Result < InvocationArg > {
400395 let args: errors:: Result < Vec < InvocationArg > > = vec
401396 . iter ( )
402- . map ( |elem| InvocationArg :: try_from ( elem ) )
397+ . map ( InvocationArg :: try_from)
403398 . collect ( ) ;
404399 let res =
405400 Jvm :: do_create_java_list ( cache:: get_thread_local_env ( ) ?, cache:: J4RS_ARRAY , & args?) ;
@@ -423,7 +418,7 @@ impl<'a> TryFrom<&'a [char]> for InvocationArg {
423418 fn try_from ( vec : & ' a [ char ] ) -> errors:: Result < InvocationArg > {
424419 let args: errors:: Result < Vec < InvocationArg > > = vec
425420 . iter ( )
426- . map ( |elem| InvocationArg :: try_from ( elem ) )
421+ . map ( InvocationArg :: try_from)
427422 . collect ( ) ;
428423 let res =
429424 Jvm :: do_create_java_list ( cache:: get_thread_local_env ( ) ?, cache:: J4RS_ARRAY , & args?) ;
@@ -447,7 +442,7 @@ impl<'a> TryFrom<&'a [i16]> for InvocationArg {
447442 fn try_from ( vec : & ' a [ i16 ] ) -> errors:: Result < InvocationArg > {
448443 let args: errors:: Result < Vec < InvocationArg > > = vec
449444 . iter ( )
450- . map ( |elem| InvocationArg :: try_from ( elem ) )
445+ . map ( InvocationArg :: try_from)
451446 . collect ( ) ;
452447 let res =
453448 Jvm :: do_create_java_list ( cache:: get_thread_local_env ( ) ?, cache:: J4RS_ARRAY , & args?) ;
@@ -471,7 +466,7 @@ impl<'a> TryFrom<&'a [u16]> for InvocationArg {
471466 fn try_from ( vec : & ' a [ u16 ] ) -> errors:: Result < InvocationArg > {
472467 let args: errors:: Result < Vec < InvocationArg > > = vec
473468 . iter ( )
474- . map ( |elem| InvocationArg :: try_from ( elem ) )
469+ . map ( InvocationArg :: try_from)
475470 . collect ( ) ;
476471 let res =
477472 Jvm :: do_create_java_list ( cache:: get_thread_local_env ( ) ?, cache:: J4RS_ARRAY , & args?) ;
@@ -495,7 +490,7 @@ impl<'a> TryFrom<&'a [i32]> for InvocationArg {
495490 fn try_from ( vec : & ' a [ i32 ] ) -> errors:: Result < InvocationArg > {
496491 let args: errors:: Result < Vec < InvocationArg > > = vec
497492 . iter ( )
498- . map ( |elem| InvocationArg :: try_from ( elem ) )
493+ . map ( InvocationArg :: try_from)
499494 . collect ( ) ;
500495 let res =
501496 Jvm :: do_create_java_list ( cache:: get_thread_local_env ( ) ?, cache:: J4RS_ARRAY , & args?) ;
@@ -515,7 +510,7 @@ impl<'a> TryFrom<&'a [i64]> for InvocationArg {
515510 fn try_from ( vec : & ' a [ i64 ] ) -> errors:: Result < InvocationArg > {
516511 let args: errors:: Result < Vec < InvocationArg > > = vec
517512 . iter ( )
518- . map ( |elem| InvocationArg :: try_from ( elem ) )
513+ . map ( InvocationArg :: try_from)
519514 . collect ( ) ;
520515 let res =
521516 Jvm :: do_create_java_list ( cache:: get_thread_local_env ( ) ?, cache:: J4RS_ARRAY , & args?) ;
@@ -539,7 +534,7 @@ impl<'a> TryFrom<&'a [f32]> for InvocationArg {
539534 fn try_from ( vec : & ' a [ f32 ] ) -> errors:: Result < InvocationArg > {
540535 let args: errors:: Result < Vec < InvocationArg > > = vec
541536 . iter ( )
542- . map ( |elem| InvocationArg :: try_from ( elem ) )
537+ . map ( InvocationArg :: try_from)
543538 . collect ( ) ;
544539 let res =
545540 Jvm :: do_create_java_list ( cache:: get_thread_local_env ( ) ?, cache:: J4RS_ARRAY , & args?) ;
@@ -563,7 +558,7 @@ impl<'a> TryFrom<&'a [f64]> for InvocationArg {
563558 fn try_from ( vec : & ' a [ f64 ] ) -> errors:: Result < InvocationArg > {
564559 let args: errors:: Result < Vec < InvocationArg > > = vec
565560 . iter ( )
566- . map ( |elem| InvocationArg :: try_from ( elem ) )
561+ . map ( InvocationArg :: try_from)
567562 . collect ( ) ;
568563 let res =
569564 Jvm :: do_create_java_list ( cache:: get_thread_local_env ( ) ?, cache:: J4RS_ARRAY , & args?) ;
0 commit comments