base_traits/traits/
infinity.rs

1// src/traits/infinity.rs : `Infinity`
2
3/// Trait defining class method `infinity() : T` that creates an instance of
4/// the implementing type that is conceptually (or actually) infinity.
5///
6/// # Additional Implementations on Foreign Types
7///
8/// ## Built-in Types
9///
10/// If the feature `"implement-Infinity-for-built_ins"`
11/// is defined (as it is by `"default"`), then this is also implemented
12/// for the following types:
13/// - [`f32`];
14/// - [`f64`];
15pub trait Infinity {
16    fn infinity() -> Self;
17}
18
19
20#[cfg(feature = "implement-Infinity-for-built_ins")]
21mod impl_for_built_ins {
22    #![allow(non_snake_case)]
23
24    macro_rules! implement_Infinity_ {
25        ($type:tt) => {
26            impl super::Infinity for $type {
27                #[inline]
28                fn infinity() -> Self {
29                    $type::INFINITY
30                }
31            }
32        };
33    }
34
35    implement_Infinity_!(f32);
36    implement_Infinity_!(f64);
37}
38
39
40// ///////////////////////////// end of file //////////////////////////// //
41