1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
pub( crate ) mod private
{
use crate::*;
pub trait NanLikeInterface
{
fn make_nan_like() -> Self;
fn is_nan( &self ) -> bool;
}
macro_rules! impl_nan_like_for_integer
{
(
$( $Args : tt )*
) =>
{
impl NanLikeInterface for $( $Args )*
{
#[ inline ]
fn make_nan_like() -> Self
{
0
}
#[ inline ]
fn is_nan( &self ) -> bool
{
false
}
}
};
}
macro_rules! impl_nan_like_for_float
{
(
$( $Args : tt )*
) =>
{
impl NanLikeInterface for $( $Args )*
{
#[ inline ]
fn make_nan_like() -> Self
{
< $( $Args )* >::NAN
}
#[ inline ]
fn is_nan( &self ) -> bool
{
*self == < $( $Args )* >::NAN
}
}
};
}
for_each_int!( impl_nan_like_for_integer );
for_each_float!( impl_nan_like_for_float );
}
crate::mod_interface!
{
prelude use NanLikeInterface;
}