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
#![doc = include_str!("readme.md")]

/// Returns the minimum of two values.
#[inline(always)]
pub fn min2<'a, 'b, 'c, T>(a: &'a T, b: &'b T) -> &'c T
where
    T: PartialOrd,
    'a: 'c,
    'b: 'c,
{
    if a < b { a } else { b }
}
/// Returns the maximum of two values.
#[inline(always)]
pub fn max2<'a, 'b, 'c, T>(a: &'a T, b: &'b T) -> &'c T
where
    T: PartialOrd,
    'a: 'c,
    'b: 'c,
{
    if a > b { a } else { b }
}
/// Returns the minimum of three values.
#[inline(always)]
pub fn min3<'a, 'b, 'c, 'd, T>(a: &'a T, b: &'b T, c: &'c T) -> &'d T
where
    T: PartialOrd,
    'a: 'd,
    'b: 'd,
    'c: 'd,
{
    min2(min2(a, b), c)
}
/// Returns the maximum of three values.
#[inline(always)]
pub fn max3<'a, 'b, 'c, 'd, T>(a: &'a T, b: &'b T, c: &'c T) -> &'d T
where
    T: PartialOrd,
    'a: 'd,
    'b: 'd,
    'c: 'd,
{
    max2(max2(a, b), c)
}