@@ -23,21 +23,21 @@ use num_order::NumHash;
23
23
type FBig = dashu_float:: FBig ;
24
24
25
25
// error messages
26
- const ERRMSG_LENGTH_TOO_LARGE : & ' static str = "the integer has too many bits for indexing" ;
27
- const ERRMSG_STEPSIZE_TOO_LARGE : & ' static str =
26
+ const ERRMSG_LENGTH_TOO_LARGE : & str = "the integer has too many bits for indexing" ;
27
+ const ERRMSG_STEPSIZE_TOO_LARGE : & str =
28
28
"bit slicing with step size larger than 1 is not supported yet" ;
29
- const ERRMSG_UBIG_WRONG_SRC_TYPE : & ' static str =
29
+ const ERRMSG_UBIG_WRONG_SRC_TYPE : & str =
30
30
"only integers or strings can be used to construct a UBig instance" ;
31
- const ERRMSG_IBIG_WRONG_SRC_TYPE : & ' static str =
31
+ const ERRMSG_IBIG_WRONG_SRC_TYPE : & str =
32
32
"only integers or strings can be used to construct an IBig instance" ;
33
- const ERRMSG_FROM_WORDS_WRONG_TYPE : & ' static str =
33
+ const ERRMSG_FROM_WORDS_WRONG_TYPE : & str =
34
34
"only list of integers or Words instance can be used in UBig.from_words()" ;
35
- const ERRMSG_WRONG_ENDIANNESS : & ' static str = "byteorder must be either 'little' or 'big'" ;
36
- const ERRMSG_NEGATIVE_TO_UNSIGNED : & ' static str = "can't convert negative int to unsigned" ;
37
- const ERRMSG_INT_WITH_RADIX : & ' static str = "can't convert non-string with explicit base" ;
38
- const ERRMSG_WRONG_INDEX_TYPE : & ' static str = "indices must be integers or slices" ;
39
- const ERRMSG_UBIG_BITS_OOR : & ' static str = "bits index out of range" ;
40
- const ERRMSG_BITOPS_TYPE : & ' static str = "bit operations are only defined between integers" ;
35
+ const ERRMSG_WRONG_ENDIANNESS : & str = "byteorder must be either 'little' or 'big'" ;
36
+ const ERRMSG_NEGATIVE_TO_UNSIGNED : & str = "can't convert negative int to unsigned" ;
37
+ const ERRMSG_INT_WITH_RADIX : & str = "can't convert non-string with explicit base" ;
38
+ const ERRMSG_WRONG_INDEX_TYPE : & str = "indices must be integers or slices" ;
39
+ const ERRMSG_UBIG_BITS_OOR : & str = "bits index out of range" ;
40
+ const ERRMSG_BITOPS_TYPE : & str = "bit operations are only defined between integers" ;
41
41
42
42
macro_rules! impl_binops {
43
43
( $ty_variant: ident, $py_method: ident, $rs_method: ident) => {
@@ -373,7 +373,7 @@ impl UPy {
373
373
}
374
374
/// Convert the integer to bytes, like int.to_bytes().
375
375
fn to_bytes ( & self , byteorder : Option < & str > , py : Python ) -> PyResult < PyObject > {
376
- let byteorder = byteorder. unwrap_or ( & "little" ) ;
376
+ let byteorder = byteorder. unwrap_or ( "little" ) ;
377
377
let bytes = match byteorder {
378
378
"little" => PyBytes :: new ( py, & self . 0 . to_le_bytes ( ) ) ,
379
379
"big" => PyBytes :: new ( py, & self . 0 . to_be_bytes ( ) ) ,
@@ -386,7 +386,7 @@ impl UPy {
386
386
/// Create UBig from bytes, like int.from_bytes().
387
387
#[ staticmethod]
388
388
fn from_bytes ( bytes : & PyBytes , byteorder : Option < & str > ) -> PyResult < Self > {
389
- let byteorder = byteorder. unwrap_or ( & "little" ) ;
389
+ let byteorder = byteorder. unwrap_or ( "little" ) ;
390
390
let uint = match byteorder {
391
391
"little" => UBig :: from_le_bytes ( bytes. as_bytes ( ) ) ,
392
392
"big" => UBig :: from_be_bytes ( bytes. as_bytes ( ) ) ,
@@ -400,35 +400,35 @@ impl UPy {
400
400
/********** operators **********/
401
401
#[ inline]
402
402
fn __add__ ( & self , other : UniInput < ' _ > , py : Python ) -> PyObject {
403
- upy_add ( & self , other, py)
403
+ upy_add ( self , other, py)
404
404
}
405
405
#[ inline]
406
406
fn __radd__ ( & self , other : UniInput < ' _ > , py : Python ) -> PyObject {
407
- upy_add ( & self , other, py)
407
+ upy_add ( self , other, py)
408
408
}
409
409
#[ inline]
410
410
fn __sub__ ( & self , other : UniInput < ' _ > , py : Python ) -> PyObject {
411
- upy_sub ( & self , other, py)
411
+ upy_sub ( self , other, py)
412
412
}
413
413
#[ inline]
414
414
fn __rsub__ ( & self , other : UniInput < ' _ > , py : Python ) -> PyObject {
415
- upy_rsub ( other, & self , py)
415
+ upy_rsub ( other, self , py)
416
416
}
417
417
#[ inline]
418
418
fn __mul__ ( & self , other : UniInput < ' _ > , py : Python ) -> PyObject {
419
- upy_mul ( & self , other, py)
419
+ upy_mul ( self , other, py)
420
420
}
421
421
#[ inline]
422
422
fn __rmul__ ( & self , other : UniInput < ' _ > , py : Python ) -> PyObject {
423
- upy_mul ( & self , other, py)
423
+ upy_mul ( self , other, py)
424
424
}
425
425
#[ inline]
426
426
fn __truediv__ ( & self , other : UniInput < ' _ > , py : Python ) -> PyObject {
427
- upy_div ( & self , other, py)
427
+ upy_div ( self , other, py)
428
428
}
429
429
#[ inline]
430
430
fn __rtruediv__ ( & self , other : UniInput < ' _ > , py : Python ) -> PyObject {
431
- upy_rdiv ( other, & self , py)
431
+ upy_rdiv ( other, self , py)
432
432
}
433
433
#[ inline]
434
434
fn __mod__ ( & self , other : UniInput < ' _ > , py : Python ) -> PyObject {
@@ -546,35 +546,35 @@ impl IPy {
546
546
/********** operators **********/
547
547
#[ inline]
548
548
fn __add__ ( & self , other : UniInput < ' _ > , py : Python ) -> PyObject {
549
- ipy_add ( & self , other, py)
549
+ ipy_add ( self , other, py)
550
550
}
551
551
#[ inline]
552
552
fn __radd__ ( & self , other : UniInput < ' _ > , py : Python ) -> PyObject {
553
- ipy_add ( & self , other, py)
553
+ ipy_add ( self , other, py)
554
554
}
555
555
#[ inline]
556
556
fn __sub__ ( & self , other : UniInput < ' _ > , py : Python ) -> PyObject {
557
- ipy_sub ( & self , other, py)
557
+ ipy_sub ( self , other, py)
558
558
}
559
559
#[ inline]
560
560
fn __rsub__ ( & self , other : UniInput < ' _ > , py : Python ) -> PyObject {
561
- ipy_rsub ( other, & self , py)
561
+ ipy_rsub ( other, self , py)
562
562
}
563
563
#[ inline]
564
564
fn __mul__ ( & self , other : UniInput < ' _ > , py : Python ) -> PyObject {
565
- ipy_mul ( & self , other, py)
565
+ ipy_mul ( self , other, py)
566
566
}
567
567
#[ inline]
568
568
fn __rmul__ ( & self , other : UniInput < ' _ > , py : Python ) -> PyObject {
569
- ipy_mul ( & self , other, py)
569
+ ipy_mul ( self , other, py)
570
570
}
571
571
#[ inline]
572
572
fn __truediv__ ( & self , other : UniInput < ' _ > , py : Python ) -> PyObject {
573
- ipy_div ( & self , other, py)
573
+ ipy_div ( self , other, py)
574
574
}
575
575
#[ inline]
576
576
fn __rtruediv__ ( & self , other : UniInput < ' _ > , py : Python ) -> PyObject {
577
- ipy_rdiv ( other, & self , py)
577
+ ipy_rdiv ( other, self , py)
578
578
}
579
579
#[ inline]
580
580
fn __mod__ ( & self , other : UniInput < ' _ > , py : Python ) -> PyObject {
@@ -645,7 +645,7 @@ impl IPy {
645
645
return Err ( PyOverflowError :: new_err ( ERRMSG_NEGATIVE_TO_UNSIGNED ) ) ;
646
646
}
647
647
648
- let byteorder = byteorder. unwrap_or ( & "little" ) ;
648
+ let byteorder = byteorder. unwrap_or ( "little" ) ;
649
649
let bytes = match byteorder {
650
650
"little" => PyBytes :: new ( py, & self . 0 . to_le_bytes ( ) ) ,
651
651
"big" => PyBytes :: new ( py, & self . 0 . to_be_bytes ( ) ) ,
@@ -662,7 +662,7 @@ impl IPy {
662
662
byteorder : Option < & str > ,
663
663
signed : Option < bool > ,
664
664
) -> PyResult < Self > {
665
- let byteorder = byteorder. unwrap_or ( & "little" ) ;
665
+ let byteorder = byteorder. unwrap_or ( "little" ) ;
666
666
let signed = signed. unwrap_or ( false ) ;
667
667
let int = match byteorder {
668
668
"little" => match signed {
0 commit comments