base_traits/traits/
is_infinity.rs

1// src/traits/is_infinity.rs : `IsInfinity`
2
3/// Trait defining instance method `is_infinity() : bool` that indicates
4/// whether the implementing type instance is conceptually (or actually)
5/// infinite.
6///
7/// # Additional Implementations on Foreign Types
8///
9/// ## Built-in Types
10///
11/// If the feature `"implement-IsInfinity-for-built_ins"`
12/// is defined (as it is by `"default"`), then this is also implemented
13/// for the following types:
14/// - [`f32`];
15/// - [`f64`];
16pub trait IsInfinity {
17    fn is_infinity(&self) -> bool;
18}
19
20
21impl<T : IsInfinity + ?Sized> IsInfinity for Box<T> {
22    fn is_infinity(&self) -> bool {
23        (**self).is_infinity()
24    }
25}
26
27impl<T : IsInfinity + ?Sized> IsInfinity for std::rc::Rc<T> {
28    fn is_infinity(&self) -> bool {
29        (**self).is_infinity()
30    }
31}
32
33
34#[cfg(feature = "implement-IsInfinity-for-built_ins")]
35mod impl_for_built_ins {
36    #![allow(non_snake_case)]
37
38    macro_rules! implement_IsInfinity_ {
39        ($type:tt) => {
40            impl super::IsInfinity for $type {
41                #[inline]
42                fn is_infinity(&self) -> bool {
43                    (*self).is_infinite()
44                }
45            }
46        };
47    }
48
49    implement_IsInfinity_!(f32);
50    implement_IsInfinity_!(f64);
51}
52
53
54// ///////////////////////////// end of file //////////////////////////// //
55