@@ -5,21 +5,7 @@ macro_rules! int {
55 ( $n: expr) => { {
66 const VALUE : $crate:: Int = match $crate:: Int :: new( $n) {
77 Some ( int) => int,
8- None => {
9- // Hack to emulate a panic in this case.
10- // Inspired by the [`static_assertions`](https://github.com/nvzqz/static-assertions) package.
11- // Improvements to be made with higher MSRVs:
12- // * 1.48: Replace the number comparison with `Option::is_none`
13- // * 1.57: Use `panic!()` directly.
14- // * 1.83: Replace manual `panic!()` with `Option::expect`
15- const _: [ ( ) ; 0 - !{
16- const ASSERT : bool = $n >= $crate:: MIN_SAFE_INT && $n <= $crate:: MAX_SAFE_INT ;
17- ASSERT
18- } as usize ] = [ ] ;
19- // This loop should not run, but it produces a never type that keeps the match
20- // arms having the same type (since never conforms to any type)
21- loop { }
22- }
8+ None => panic!( "Number is outside the range of an Int" ) ,
239 } ;
2410 VALUE
2511 } } ;
@@ -32,22 +18,7 @@ macro_rules! uint {
3218 ( $n: expr) => { {
3319 const VALUE : $crate:: UInt = match $crate:: UInt :: new( $n) {
3420 Some ( int) => int,
35- None => {
36- // Hack to emulate a panic in this case.
37- // Inspired by the [`static_assertions`](https://github.com/nvzqz/static-assertions) package.
38- // Improvements to be made with higher MSRVs:
39- // * 1.48: Replace the number comparison with `Option::is_none`
40- // * 1.57: Use `panic!()` directly.
41- // * 1.83: Replace manual `panic!()` with `Option::expect`
42- #[ allow( unknown_lints, unused_comparisons) ]
43- const _: [ ( ) ; 0 - !{
44- const ASSERT : bool = $n <= $crate:: MAX_SAFE_UINT ;
45- ASSERT
46- } as usize ] = [ ] ;
47- // This loop should not run, but it produces a never type that keeps the match
48- // arms having the same type (since never conforms to any type)
49- loop { }
50- }
21+ None => panic!( "Number is outside the range of an Int" ) ,
5122 } ;
5223 VALUE
5324 } } ;
0 commit comments