@@ -17,7 +17,7 @@ fn cid_hash_to_pydict<'py>(py: Python<'py>, cid: &Cid) -> Bound<'py, PyDict> {
1717 dict_obj. set_item ( "code" , hash. code ( ) ) . unwrap ( ) ;
1818 dict_obj. set_item ( "size" , hash. size ( ) ) . unwrap ( ) ;
1919 dict_obj
20- . set_item ( "digest" , PyBytes :: new ( py, & hash. digest ( ) ) )
20+ . set_item ( "digest" , PyBytes :: new ( py, hash. digest ( ) ) )
2121 . unwrap ( ) ;
2222
2323 dict_obj
@@ -80,7 +80,7 @@ fn sort_map_keys(keys: &Bound<PyList>, len: usize) -> Result<Vec<(PyBackedStr, u
8080 if s1. len ( ) != s2. len ( ) {
8181 s1. len ( ) . cmp ( & s2. len ( ) )
8282 } else {
83- s1. cmp ( & s2)
83+ s1. cmp ( s2)
8484 }
8585 } ) ;
8686
@@ -219,7 +219,7 @@ fn decode_dag_cbor_to_pyobject<R: Read + Seek>(
219219}
220220
221221fn encode_dag_cbor_from_pyobject < ' py , W : Write > (
222- py : Python < ' py > ,
222+ _py : Python < ' py > ,
223223 obj : & Bound < ' py , PyAny > ,
224224 w : & mut W ,
225225) -> Result < ( ) > {
@@ -274,7 +274,7 @@ fn encode_dag_cbor_from_pyobject<'py, W: Write>(
274274 encode:: write_u64 ( w, MajorKind :: Array , len as u64 ) ?;
275275
276276 for i in 0 ..len {
277- encode_dag_cbor_from_pyobject ( py , & l. get_item ( i) ?, w) ?;
277+ encode_dag_cbor_from_pyobject ( _py , & l. get_item ( i) ?, w) ?;
278278 }
279279
280280 Ok ( ( ) )
@@ -290,7 +290,7 @@ fn encode_dag_cbor_from_pyobject<'py, W: Write>(
290290 encode:: write_u64 ( w, MajorKind :: TextString , key_buf. len ( ) as u64 ) ?;
291291 w. write_all ( key_buf) ?;
292292
293- encode_dag_cbor_from_pyobject ( py , & values. get_item ( i) ?, w) ?;
293+ encode_dag_cbor_from_pyobject ( _py , & values. get_item ( i) ?, w) ?;
294294 }
295295
296296 Ok ( ( ) )
@@ -308,7 +308,7 @@ fn encode_dag_cbor_from_pyobject<'py, W: Write>(
308308 } else if let Ok ( b) = obj. cast :: < PyBytes > ( ) {
309309 // FIXME (MarshalX): it's not efficient to try to parse it as CID
310310 let cid = Cid :: try_from ( b. as_bytes ( ) ) ;
311- if let Ok ( _ ) = cid {
311+ if cid . is_ok ( ) {
312312 let buf = b. as_bytes ( ) ;
313313 let len = buf. len ( ) ;
314314
@@ -360,7 +360,7 @@ fn read_u64_leb128<R: Read>(r: &mut R) -> Result<u64> {
360360
361361 loop {
362362 let mut buf = [ 0 ] ;
363- if let Err ( _ ) = r. read_exact ( & mut buf) {
363+ if r. read_exact ( & mut buf) . is_err ( ) {
364364 return Err ( anyhow ! ( "Unexpected EOF while reading ULEB128 number." ) ) ;
365365 }
366366
@@ -405,7 +405,7 @@ fn read_cid_from_bytes<R: Read>(r: &mut R) -> CidResult<Cid> {
405405pub fn decode_car < ' py > ( py : Python < ' py > , data : & [ u8 ] ) -> PyResult < ( Py < PyAny > , Bound < ' py , PyDict > ) > {
406406 let buf = & mut BufReader :: new ( Cursor :: new ( data) ) ;
407407
408- if let Err ( _ ) = read_u64_leb128 ( buf) {
408+ if read_u64_leb128 ( buf) . is_err ( ) {
409409 return Err ( get_err (
410410 "Failed to read CAR header" ,
411411 "Invalid uvarint" . to_string ( ) ,
@@ -451,7 +451,7 @@ pub fn decode_car<'py>(py: Python<'py>, data: &[u8]) -> PyResult<(Py<PyAny>, Bou
451451 let parsed_blocks = PyDict :: new ( py) ;
452452
453453 loop {
454- if let Err ( _ ) = read_u64_leb128 ( buf) {
454+ if read_u64_leb128 ( buf) . is_err ( ) {
455455 // FIXME (MarshalX): we are not raising an error here because of possible EOF
456456 break ;
457457 }
@@ -532,10 +532,10 @@ pub fn encode_dag_cbor<'py>(
532532 if let Err ( e) = buf. flush ( ) {
533533 return Err ( get_err ( "Failed to flush buffer" , e. to_string ( ) ) ) ;
534534 }
535- Ok ( PyBytes :: new ( py, & buf. get_ref ( ) ) )
535+ Ok ( PyBytes :: new ( py, buf. get_ref ( ) ) )
536536}
537537
538- fn get_cid_from_py_any < ' py > ( data : & Bound < PyAny > ) -> PyResult < Cid > {
538+ fn get_cid_from_py_any ( data : & Bound < PyAny > ) -> PyResult < Cid > {
539539 let cid: CidResult < Cid > ;
540540 if let Ok ( s) = data. cast :: < PyString > ( ) {
541541 cid = Cid :: try_from ( s. to_str ( ) ?) ;
0 commit comments