@@ -265,82 +265,82 @@ mod tests {
265
265
assert_eq!(
266
266
ArbBitInt :: from_i64( 8 , x as i64 )
267
267
. wrapping_add( & ArbBitInt :: from_i64( 8 , y as i64 ) ) . to_sign_ext_i8( ) ,
268
- i8 :: try_from ( x. wrapping_add( y) ) . ok ( )
268
+ Some ( x. wrapping_add( y) )
269
269
) ;
270
270
// i16
271
271
assert_eq!(
272
272
ArbBitInt :: from_i64( 8 , x as i64 )
273
273
. wrapping_add( & ArbBitInt :: from_i64( 8 , y as i64 ) ) . to_sign_ext_i16( ) ,
274
- i16 :: try_from ( x. wrapping_add( y) ) . ok ( )
274
+ Some ( i16 :: from ( x. wrapping_add( y) ) )
275
275
) ;
276
276
277
277
// wrapping_sub
278
278
// i8
279
279
assert_eq!(
280
280
ArbBitInt :: from_i64( 8 , x as i64 )
281
281
. wrapping_sub( & ArbBitInt :: from_i64( 8 , y as i64 ) ) . to_sign_ext_i8( ) ,
282
- i8 :: try_from ( x. wrapping_sub( y) ) . ok ( )
282
+ Some ( x. wrapping_sub( y) )
283
283
) ;
284
284
// i16
285
285
assert_eq!(
286
286
ArbBitInt :: from_i64( 8 , x as i64 )
287
287
. wrapping_sub( & ArbBitInt :: from_i64( 8 , y as i64 ) ) . to_sign_ext_i16( ) ,
288
- i16 :: try_from ( x. wrapping_sub( y) ) . ok ( )
288
+ Some ( i16 :: from ( x. wrapping_sub( y) ) )
289
289
) ;
290
290
291
291
// wrapping_mul
292
292
// i8
293
293
assert_eq!(
294
294
ArbBitInt :: from_i64( 8 , x as i64 )
295
295
. wrapping_mul( & ArbBitInt :: from_i64( 8 , y as i64 ) ) . to_sign_ext_i8( ) ,
296
- i8 :: try_from ( x. wrapping_mul( y) ) . ok ( )
296
+ Some ( x. wrapping_mul( y) )
297
297
) ;
298
298
// i16
299
299
assert_eq!(
300
300
ArbBitInt :: from_i64( 8 , x as i64 )
301
301
. wrapping_mul( & ArbBitInt :: from_i64( 8 , y as i64 ) ) . to_sign_ext_i16( ) ,
302
- i16 :: try_from ( x. wrapping_mul( y) ) . ok ( )
302
+ Some ( i16 :: from ( x. wrapping_mul( y) ) )
303
303
) ;
304
304
305
305
// bitadd
306
306
assert_eq!(
307
307
ArbBitInt :: from_i64( 8 , x as i64 )
308
308
. bitand( & ArbBitInt :: from_i64( 8 , y as i64 ) ) . to_sign_ext_i8( ) ,
309
- i8 :: try_from ( x. bitand( y) ) . ok ( )
309
+ Some ( x. bitand( y) )
310
310
) ;
311
311
// i16
312
312
assert_eq!(
313
313
ArbBitInt :: from_i64( 8 , x as i64 )
314
314
. bitand( & ArbBitInt :: from_i64( 8 , y as i64 ) ) . to_sign_ext_i16( ) ,
315
- i16 :: try_from ( x. bitand( y) ) . ok ( )
315
+ Some ( i16 :: from ( x. bitand( y) ) )
316
316
) ;
317
317
318
318
// bitor
319
319
// i16
320
320
assert_eq!(
321
321
ArbBitInt :: from_i64( 8 , x as i64 )
322
322
. bitor( & ArbBitInt :: from_i64( 8 , y as i64 ) ) . to_sign_ext_i8( ) ,
323
- i8 :: try_from ( x. bitor( y) ) . ok ( )
323
+ Some ( x. bitor( y) )
324
324
) ;
325
325
// i16
326
326
assert_eq!(
327
327
ArbBitInt :: from_i64( 8 , x as i64 )
328
328
. bitor( & ArbBitInt :: from_i64( 8 , y as i64 ) ) . to_sign_ext_i16( ) ,
329
- i16 :: try_from ( x. bitor( y) ) . ok ( )
329
+ Some ( i16 :: from ( x. bitor( y) ) )
330
330
) ;
331
331
332
332
// bitxor
333
333
// i8
334
334
assert_eq!(
335
335
ArbBitInt :: from_i64( 8 , x as i64 )
336
336
. bitxor( & ArbBitInt :: from_i64( 8 , y as i64 ) ) . to_sign_ext_i8( ) ,
337
- i8 :: try_from ( x. bitxor( y) ) . ok ( )
337
+ Some ( x. bitxor( y) )
338
338
) ;
339
339
// i16
340
340
assert_eq!(
341
341
ArbBitInt :: from_i64( 8 , x as i64 )
342
342
. bitxor( & ArbBitInt :: from_i64( 8 , y as i64 ) ) . to_sign_ext_i16( ) ,
343
- i16 :: try_from ( x. bitxor( y) ) . ok ( )
343
+ Some ( i16 :: from ( x. bitxor( y) ) )
344
344
) ;
345
345
}
346
346
@@ -364,7 +364,7 @@ mod tests {
364
364
assert_eq!(
365
365
ArbBitInt :: from_i64( 16 , x as i64 )
366
366
. wrapping_add( & ArbBitInt :: from_i64( 16 , y as i64 ) ) . to_sign_ext_i16( ) ,
367
- i16 :: try_from ( x. wrapping_add( y) ) . ok ( )
367
+ Some ( x. wrapping_add( y) )
368
368
) ;
369
369
370
370
// wrapping_sub
@@ -378,7 +378,7 @@ mod tests {
378
378
assert_eq!(
379
379
ArbBitInt :: from_i64( 16 , x as i64 )
380
380
. wrapping_sub( & ArbBitInt :: from_i64( 16 , y as i64 ) ) . to_sign_ext_i16( ) ,
381
- i16 :: try_from ( x. wrapping_sub( y) ) . ok ( )
381
+ Some ( x. wrapping_sub( y) )
382
382
) ;
383
383
384
384
// wrapping_mul
@@ -392,7 +392,7 @@ mod tests {
392
392
assert_eq!(
393
393
ArbBitInt :: from_i64( 16 , x as i64 )
394
394
. wrapping_mul( & ArbBitInt :: from_i64( 16 , y as i64 ) ) . to_sign_ext_i16( ) ,
395
- i16 :: try_from ( x. wrapping_mul( y) ) . ok ( )
395
+ Some ( x. wrapping_mul( y) )
396
396
) ;
397
397
398
398
// bitand
@@ -406,7 +406,7 @@ mod tests {
406
406
assert_eq!(
407
407
ArbBitInt :: from_i64( 16 , x as i64 )
408
408
. bitand( & ArbBitInt :: from_i64( 16 , y as i64 ) ) . to_sign_ext_i16( ) ,
409
- i16 :: try_from ( x. bitand( y) ) . ok ( )
409
+ Some ( x. bitand( y) )
410
410
) ;
411
411
412
412
// bitor
@@ -420,7 +420,7 @@ mod tests {
420
420
assert_eq!(
421
421
ArbBitInt :: from_i64( 16 , x as i64 )
422
422
. bitor( & ArbBitInt :: from_i64( 16 , y as i64 ) ) . to_sign_ext_i16( ) ,
423
- i16 :: try_from ( x. bitor( y) ) . ok ( )
423
+ Some ( x. bitor( y) )
424
424
) ;
425
425
426
426
// bitxor
@@ -434,7 +434,7 @@ mod tests {
434
434
assert_eq!(
435
435
ArbBitInt :: from_i64( 16 , x as i64 )
436
436
. bitxor( & ArbBitInt :: from_i64( 16 , y as i64 ) ) . to_sign_ext_i16( ) ,
437
- i16 :: try_from ( x. bitxor( y) ) . ok ( )
437
+ Some ( x. bitxor( y) )
438
438
) ;
439
439
}
440
440
@@ -469,7 +469,7 @@ mod tests {
469
469
assert_eq!(
470
470
ArbBitInt :: from_i64( 32 , x as i64 )
471
471
. wrapping_add( & ArbBitInt :: from_i64( 32 , y as i64 ) ) . to_sign_ext_i32( ) ,
472
- i32 :: try_from ( x. wrapping_add( y) ) . ok ( )
472
+ Some ( x. wrapping_add( y) )
473
473
) ;
474
474
475
475
// wrapping_sub
@@ -489,7 +489,7 @@ mod tests {
489
489
assert_eq!(
490
490
ArbBitInt :: from_i64( 32 , x as i64 )
491
491
. wrapping_sub( & ArbBitInt :: from_i64( 32 , y as i64 ) ) . to_sign_ext_i32( ) ,
492
- i32 :: try_from ( x. wrapping_sub( y) ) . ok ( )
492
+ Some ( x. wrapping_sub( y) )
493
493
) ;
494
494
495
495
// wrapping_mul
@@ -509,7 +509,7 @@ mod tests {
509
509
assert_eq!(
510
510
ArbBitInt :: from_i64( 32 , x as i64 )
511
511
. wrapping_mul( & ArbBitInt :: from_i64( 32 , y as i64 ) ) . to_sign_ext_i32( ) ,
512
- i32 :: try_from ( x. wrapping_mul( y) ) . ok ( )
512
+ Some ( x. wrapping_mul( y) )
513
513
) ;
514
514
515
515
// bitand
@@ -529,7 +529,7 @@ mod tests {
529
529
assert_eq!(
530
530
ArbBitInt :: from_i64( 32 , x as i64 )
531
531
. bitand( & ArbBitInt :: from_i64( 32 , y as i64 ) ) . to_sign_ext_i32( ) ,
532
- i32 :: try_from ( x. bitand( y) ) . ok ( )
532
+ Some ( x. bitand( y) )
533
533
) ;
534
534
535
535
// bitor
@@ -549,7 +549,7 @@ mod tests {
549
549
assert_eq!(
550
550
ArbBitInt :: from_i64( 32 , x as i64 )
551
551
. bitor( & ArbBitInt :: from_i64( 32 , y as i64 ) ) . to_sign_ext_i32( ) ,
552
- i32 :: try_from ( x. bitor( y) ) . ok ( )
552
+ Some ( x. bitor( y) )
553
553
) ;
554
554
555
555
// bitxor
@@ -569,7 +569,7 @@ mod tests {
569
569
assert_eq!(
570
570
ArbBitInt :: from_i64( 32 , x as i64 )
571
571
. bitxor( & ArbBitInt :: from_i64( 32 , y as i64 ) ) . to_sign_ext_i32( ) ,
572
- i32 :: try_from ( x. bitxor( y) ) . ok ( )
572
+ Some ( x. bitxor( y) )
573
573
) ;
574
574
}
575
575
@@ -615,7 +615,7 @@ mod tests {
615
615
assert_eq!(
616
616
ArbBitInt :: from_i64( 64 , x)
617
617
. wrapping_add( & ArbBitInt :: from_i64( 64 , y) ) . to_sign_ext_i64( ) ,
618
- i64 :: try_from ( x. wrapping_add( y) ) . ok ( )
618
+ Some ( x. wrapping_add( y) )
619
619
) ;
620
620
621
621
// wrapping_sub
@@ -641,7 +641,7 @@ mod tests {
641
641
assert_eq!(
642
642
ArbBitInt :: from_i64( 64 , x)
643
643
. wrapping_sub( & ArbBitInt :: from_i64( 64 , y) ) . to_sign_ext_i64( ) ,
644
- i64 :: try_from ( x. wrapping_sub( y) ) . ok ( )
644
+ Some ( x. wrapping_sub( y) )
645
645
) ;
646
646
647
647
// wrapping_mul
@@ -667,7 +667,7 @@ mod tests {
667
667
assert_eq!(
668
668
ArbBitInt :: from_i64( 64 , x)
669
669
. wrapping_mul( & ArbBitInt :: from_i64( 64 , y) ) . to_sign_ext_i64( ) ,
670
- i64 :: try_from ( x. wrapping_mul( y) ) . ok ( )
670
+ Some ( x. wrapping_mul( y) )
671
671
) ;
672
672
673
673
// bitand
@@ -693,7 +693,7 @@ mod tests {
693
693
assert_eq!(
694
694
ArbBitInt :: from_i64( 64 , x)
695
695
. bitand( & ArbBitInt :: from_i64( 64 , y) ) . to_sign_ext_i64( ) ,
696
- i64 :: try_from ( x. bitand( y) ) . ok ( )
696
+ Some ( x. bitand( y) )
697
697
) ;
698
698
699
699
// bitor
@@ -719,7 +719,7 @@ mod tests {
719
719
assert_eq!(
720
720
ArbBitInt :: from_i64( 64 , x)
721
721
. bitor( & ArbBitInt :: from_i64( 64 , y) ) . to_sign_ext_i64( ) ,
722
- i64 :: try_from ( x. bitor( y) ) . ok ( )
722
+ Some ( x. bitor( y) )
723
723
) ;
724
724
725
725
// bitxor
@@ -745,7 +745,7 @@ mod tests {
745
745
assert_eq!(
746
746
ArbBitInt :: from_i64( 64 , x)
747
747
. bitxor( & ArbBitInt :: from_i64( 64 , y) ) . to_sign_ext_i64( ) ,
748
- i64 :: try_from ( x. bitxor( y) ) . ok ( )
748
+ Some ( x. bitxor( y) )
749
749
) ;
750
750
}
751
751
@@ -756,7 +756,7 @@ mod tests {
756
756
// "failure cases only".
757
757
assert_eq!(
758
758
ArbBitInt :: from_u64( 8 , x as u64 ) . checked_shl( y) . map( |x| x. to_zero_ext_u8( ) ) ,
759
- x. checked_shl( y) . map( |x| u8 :: try_from ( x ) . ok ( ) )
759
+ x. checked_shl( y) . map( Some )
760
760
) ;
761
761
}
762
762
@@ -767,7 +767,7 @@ mod tests {
767
767
// "failure cases only".
768
768
assert_eq!(
769
769
ArbBitInt :: from_u64( 16 , x as u64 ) . checked_shl( y) . map( |x| x. to_zero_ext_u16( ) ) ,
770
- x. checked_shl( y) . map( |x| u16 :: try_from ( x ) . ok ( ) )
770
+ x. checked_shl( y) . map( Some )
771
771
) ;
772
772
}
773
773
@@ -778,7 +778,7 @@ mod tests {
778
778
// "failure cases only".
779
779
assert_eq!(
780
780
ArbBitInt :: from_u64( 32 , x as u64 ) . checked_shl( y) . map( |x| x. to_zero_ext_u32( ) ) ,
781
- x. checked_shl( y) . map( |x| u32 :: try_from ( x ) . ok ( ) )
781
+ x. checked_shl( y) . map( Some )
782
782
) ;
783
783
}
784
784
@@ -789,7 +789,7 @@ mod tests {
789
789
// "failure cases only".
790
790
assert_eq!(
791
791
ArbBitInt :: from_u64( 64 , x) . checked_shl( y) . map( |x| x. to_zero_ext_u64( ) ) ,
792
- x. checked_shl( y) . map( |x| u64 :: try_from ( x ) . ok ( ) )
792
+ x. checked_shl( y) . map( Some )
793
793
) ;
794
794
}
795
795
@@ -800,7 +800,7 @@ mod tests {
800
800
// "failure cases only".
801
801
assert_eq!(
802
802
ArbBitInt :: from_u64( 8 , x as u64 ) . checked_shr( y) . map( |x| x. to_zero_ext_u8( ) ) ,
803
- x. checked_shr( y) . map( |x| u8 :: try_from ( x ) . ok ( ) )
803
+ x. checked_shr( y) . map( Some )
804
804
) ;
805
805
}
806
806
@@ -811,7 +811,7 @@ mod tests {
811
811
// "failure cases only".
812
812
assert_eq!(
813
813
ArbBitInt :: from_u64( 16 , x as u64 ) . checked_shr( y) . map( |x| x. to_zero_ext_u16( ) ) ,
814
- x. checked_shr( y) . map( |x| u16 :: try_from ( x ) . ok ( ) )
814
+ x. checked_shr( y) . map( Some )
815
815
) ;
816
816
}
817
817
@@ -822,7 +822,7 @@ mod tests {
822
822
// "failure cases only".
823
823
assert_eq!(
824
824
ArbBitInt :: from_u64( 32 , x as u64 ) . checked_shr( y) . map( |x| x. to_zero_ext_u32( ) ) ,
825
- x. checked_shr( y) . map( |x| u32 :: try_from ( x ) . ok ( ) )
825
+ x. checked_shr( y) . map( Some )
826
826
) ;
827
827
}
828
828
@@ -833,7 +833,7 @@ mod tests {
833
833
// "failure cases only".
834
834
assert_eq!(
835
835
ArbBitInt :: from_u64( 64 , x) . checked_shr( y) . map( |x| x. to_zero_ext_u64( ) ) ,
836
- x. checked_shr( y) . map( |x| u64 :: try_from ( x ) . ok ( ) )
836
+ x. checked_shr( y) . map( Some )
837
837
) ;
838
838
}
839
839
}
0 commit comments